SampleVariance returns the sample variance with Bessel's correction (divides by N−1), giving an unbiased estimator when the observations are a random sample from a larger population. Returns 0 when fewer than two observations are present.
()
| 90 | // sample from a larger population. Returns 0 when fewer than two observations |
| 91 | // are present. |
| 92 | func (s *StatVar) SampleVariance() float64 { |
| 93 | if s.count < 2 { |
| 94 | return 0 |
| 95 | } |
| 96 | return s.m2 / float64(s.count-1) |
| 97 | } |
| 98 | |
| 99 | // SampleStdDev returns the sample standard deviation with Bessel's correction |
| 100 | // (sqrt of SampleVariance). |
no outgoing calls