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

Function TestStatVar_NumericalStability

pkg/stats/statvar_test.go:99–109  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

97}
98
99func TestStatVar_NumericalStability(t *testing.T) {
100 // Test with large values close together (catastrophic cancellation case).
101 // Mean = 1e9 + 0.5, stddev should be ~0.5
102 var s StatVar
103 for range 1000 {
104 v := 1e9 + float64(s.Count()%2) // alternates between 1e9 and 1e9+1
105 s.Add(v)
106 }
107 // 500 observations at 1e9 and 500 at 1e9+1 → mean = 1e9 + 0.5
108 assert.InDelta(t, 1e9+0.5, s.Mean(), 1e-6, "stability: mean should be ~1e9+0.5")
109}
110
111func TestStatVar_MedianDoesNotMutateState(t *testing.T) {
112 var s StatVar

Callers

nothing calls this directly

Calls 3

CountMethod · 0.95
AddMethod · 0.95
MeanMethod · 0.95

Tested by

no test coverage detected