added simple confidence interval calc

This commit is contained in:
Stephen McQuay 2014-11-23 00:27:59 -08:00
parent 77feed32e3
commit b673118473
1 changed files with 7 additions and 0 deletions

View File

@ -95,6 +95,13 @@ func (os *OnlineStat) StdDev() float64 {
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 {
return fmt.Sprintf(
"%+v",