stats

package module
v0.0.0-...-a2245a9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2019 License: ISC Imports: 2 Imported by: 0

README

Basic statistics package for large streams of data

Documentation and examples can be found here:

https://godoc.org/git.riedstra.us/go/stats

Or locally at:

http://localhost:6060/pkg/git.riedstra.us/go/stats/

when you go get git.riedstra.us/go/stats and run:

godoc

Documentation

Overview

Provides some basic statisitcs functionality. Specifically tailored around dealing with large streams of data It's a Go implimentation of this:

https://www.johndcook.com/blog/skewness_kurtosis/

Example program:

package main

import (
	"git.riedstra.us/go/stats"

	"fmt"
)

func main() {
	myFakeStreamOfData := []float64{01, 04, 60, 55, 80, 06, 75, 51, 63, 10}
	myStats := &stats.Stats{}
	for _, entry := range myFakeStreamOfData {
		myStats.Push(entry)
	}
	fmt.Println(myStats.PrettyStats())
}

Example output:

Mean: 40.50
Variance: 996.72
Standard Deviation: 31.57
Skewness: -0.20
Kurtosis: -1.66

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Stats

type Stats struct {
	Max float64
	Min float64
	// contains filtered or unexported fields
}

Structure used to hold the information about the dataset. several methods are exposed in order to make your life easy

func (*Stats) Clear

func (s *Stats) Clear()

Zeros out the struct for re-use

func (*Stats) Internals

func (s *Stats) Internals() string

Returns a string containing all of the data within the struct

func (*Stats) Kurtosis

func (s *Stats) Kurtosis() float64

func (*Stats) Mean

func (s *Stats) Mean() float64

func (*Stats) NumValues

func (s *Stats) NumValues() float64

func (*Stats) PrettyStats

func (s *Stats) PrettyStats() string

Prints each calculated statistic on a line with one tab preceding it

func (*Stats) Push

func (s *Stats) Push(x float64)

This function is used to push numbers onto the struct and calculate on the fly the necessary information to output relevant statistics

func (*Stats) Skewness

func (s *Stats) Skewness() float64

func (*Stats) StandardDeviation

func (s *Stats) StandardDeviation() float64

func (*Stats) Variance

func (s *Stats) Variance() float64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL