added simple confidence interval calc

This commit is contained in:
Stephen McQuay 2014-11-23 00:27:59 -08:00
parent 77feed32e3
commit b673118473

View File

@ -95,6 +95,13 @@ func (os *OnlineStat) StdDev() float64 {
return math.Sqrt(os.Variance()) return math.Sqrt(os.Variance())
} }
func (os *OnlineStat) CI() (float64, float64) {
// 95% from http://mathworld.wolfram.com/ConfidenceInterval.html
conf := 1.95996
dev := os.StdDev() / math.Sqrt(float64(os.n))
return os.mean - dev*conf, os.mean + dev*conf
}
func (os *OnlineStat) String() string { func (os *OnlineStat) String() string {
return fmt.Sprintf( return fmt.Sprintf(
"%+v", "%+v",