An implementation of B.P. Welford's algorithm to maintain a running variance over a stream of observations.
This code is based on a John D Cook's blogpost.
s := stats.NewSink()
s.Push(-1.1813782)
s.Push(-0.2449577)
s.Push(0.8799429)
fmt.Printf("Mean = %v\n", s.Mean()) // -0.182131...
fmt.Printf("Standard Deviation = %v\n", s.StandardDeviation()) // 1.032095...
- Add a method that returns the running median.
- Make the implementation multi-goroutine safe.
- Code is released under MIT license.