MCPcopy Create free account
hub / github.com/github/gh-aw / TestSpec_PublicAPI_SampleVariance_SampleFormula

Function TestSpec_PublicAPI_SampleVariance_SampleFormula

pkg/stats/spec_test.go:85–94  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

83//
84// Example: values [2,4,4,4,5,5,7,9] (N=8, mean=5, sum_sq_dev=32) → sample variance = 32/7
85func 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.

Callers

nothing calls this directly

Calls 2

AddMethod · 0.95
SampleVarianceMethod · 0.95

Tested by

no test coverage detected