TestGradualWindowByteIdentityAtFullRing locks the invariant that the new k(n) W expression reduces bit-for-bit to the legacy "mean(m, N) + 4.0 * stddev(m, N)" once the ring is full (n == N).
(t *testing.T)
| 153 | // TestGradualWindowByteIdentityAtFullRing locks the invariant that the new k(n) W expression reduces |
| 154 | // bit-for-bit to the legacy "mean(m, N) + 4.0 * stddev(m, N)" once the ring is full (n == N). |
| 155 | func TestGradualWindowByteIdentityAtFullRing(t *testing.T) { |
| 156 | cases := []struct { |
| 157 | n int |
| 158 | legacy string |
| 159 | }{ |
| 160 | {30, "mean(m, 30) + 4.0 * stddev(m, 30)"}, |
| 161 | {100, "mean(m, 100) + 4.0 * stddev(m, 100)"}, |
| 162 | } |
| 163 | for _, tc := range cases { |
| 164 | ms := make([]float64, tc.n) |
| 165 | for i := range ms { |
| 166 | ms[i] = 100 + float64(i%7) // varied so stddev(m) > 0 |
| 167 | } |
| 168 | newExpr, err := prepareExpression(MathDefaultW) |
| 169 | require.NoError(t, err) |
| 170 | legacyExpr, err := prepareExpression(tc.legacy) |
| 171 | require.NoError(t, err) |
| 172 | // At the full ring the precomputed factor is exactly 4.0 (coverageZP), so the new scalar-k |
| 173 | // expression must reduce bit-for-bit to the legacy "mean(m,N) + 4.0*stddev(m,N)". |
| 174 | gotNew, err := newExpr.Evaluate(map[string]interface{}{ |
| 175 | "m": ms, |
| 176 | "n": float64(tc.n), |
| 177 | "k": coverageZP, |
| 178 | }) |
| 179 | require.NoError(t, err) |
| 180 | gotLegacy, err := legacyExpr.Evaluate(map[string]interface{}{"m": ms}) |
| 181 | require.NoError(t, err) |
| 182 | require.Equal(t, gotLegacy, gotNew) |
| 183 | } |
| 184 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…