welford

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

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

Go to latest
Published: Feb 5, 2024 License: MIT Imports: 1 Imported by: 32

README

welford

Package welford implements a one-pass algorithm for computing mean and variance. Knuth attributes this algorithm to B.P. Welford in The Art Of Computer Programming, Volume 2.

For an explanation of why you might want to calculate variance this way, see http://www.johndcook.com/standard_deviation.html and http://www.johndcook.com/blog/2008/09/26/comparing-three-methods-of-computing-standard-deviation/

For documentation on this package see http://godoc.org/github.com/eclesh/welford

Quick start

$ go get github.com/eclesh/welford
$ cd $GOPATH/src/github.com/eclesh/welford
$ go test

License

welford is licensed under the MIT license.

Documentation

Overview

Package stats implements Welford's one-pass algorithm for computing the mean and variance of a set of numbers. For more information see Knuth (TAOCP Vol 2, 3rd ed, pg 232).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Stats

type Stats struct {
	// contains filtered or unexported fields
}

A Stats gathers statistics on values fed into it.

func New

func New() *Stats

New returns a new Stats.

func (*Stats) Add

func (s *Stats) Add(val float64)

Add feeds a new value into the Stats.

func (*Stats) Count

func (s *Stats) Count() uint64

Count returns the total number of values seen.

func (*Stats) Max

func (s *Stats) Max() float64

Max returns the maximum value seen.

func (*Stats) Mean

func (s *Stats) Mean() float64

Mean returns the mean of all values seen.

func (*Stats) Min

func (s *Stats) Min() float64

Min returns the minimum value seen.

func (*Stats) Reset

func (s *Stats) Reset()

Reset sets all counters to zero.

func (*Stats) Stddev

func (s *Stats) Stddev() float64

Stddev returns the standard deviation of all values seen.

func (*Stats) Variance

func (s *Stats) Variance() float64

Variance returns the variance of all values seen.

Jump to

Keyboard shortcuts

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