TestSpec_PublicAPI_SampleVariance_SampleFormula validates that SampleVariance uses the sample formula with N-1 as the denominator as described in the README.md. Specification: "SampleVariance: Returns sample variance (N-1 denominator)" Example: values [2,4,4,4,5,5,7,9] (N=8, mean=5, sum_sq_dev=32)
(t *testing.T)
| 83 | // |
| 84 | // Example: values [2,4,4,4,5,5,7,9] (N=8, mean=5, sum_sq_dev=32) → sample variance = 32/7 |
| 85 | func TestSpec_PublicAPI_SampleVariance_SampleFormula(t *testing.T) { |
| 86 | var sv StatVar |
| 87 | for _, v := range []float64{2, 4, 4, 4, 5, 5, 7, 9} { |
| 88 | sv.Add(v) |
| 89 | } |
| 90 | |
| 91 | expected := 32.0 / 7.0 |
| 92 | assert.InDelta(t, expected, sv.SampleVariance(), 1e-9, |
| 93 | "SampleVariance should use N-1 (sample) denominator: sum_sq_dev / (N-1)") |
| 94 | } |
| 95 | |
| 96 | // TestSpec_PublicAPI_StdDev validates that StdDev and SampleStdDev equal the |
| 97 | // square root of their respective variances as described in the README.md. |
nothing calls this directly
no test coverage detected