added simple confidence interval calc
This commit is contained in:
parent
77feed32e3
commit
b673118473
7
ostat.go
7
ostat.go
@ -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",
|
||||||
|
Loading…
Reference in New Issue
Block a user