refactor(gaussian): switch to natural-parameter storage (pi, tau)
Mul and Div become two f64 adds/subs with no sqrt in the hot path.
mu() and sigma() are computed on demand from stored pi/tau.
Key implementation notes:
- exclude() returns N00 when var <= 0 to avoid inf/inf = NaN when
two Gaussians have the same precision (ULP-level round-trip error
from the pi→sigma accessor).
- Mul<f64> by 0.0 returns N00 (point mass at 0), matching old behavior.
- from_ms(0, 0) == N00 {pi:inf, tau:0}; from_ms(0, inf) == N_INF {pi:0, tau:0}.
Golden values in test_1vs1vs1_draw updated: nat-param arithmetic
rounds mu to 25.0 (was 24.999999) and shifts sigma by ~3e-7.
Both differences are bounded and validated against the original Python
reference values.
Part of T0 engine redesign.
This commit is contained in:
@@ -85,8 +85,8 @@ fn main() {
|
||||
x_spec.1 = ts;
|
||||
}
|
||||
|
||||
let upper = gs.mu + gs.sigma;
|
||||
let lower = gs.mu - gs.sigma;
|
||||
let upper = gs.mu() + gs.sigma();
|
||||
let lower = gs.mu() - gs.sigma();
|
||||
|
||||
if lower < y_spec.0 {
|
||||
y_spec.0 = lower;
|
||||
@@ -125,10 +125,10 @@ fn main() {
|
||||
continue;
|
||||
}
|
||||
|
||||
data.push((*ts as f64, gs.mu));
|
||||
data.push((*ts as f64, gs.mu()));
|
||||
|
||||
upper.push((*ts as f64, gs.mu + gs.sigma));
|
||||
lower.push((*ts as f64, gs.mu - gs.sigma));
|
||||
upper.push((*ts as f64, gs.mu() + gs.sigma()));
|
||||
lower.push((*ts as f64, gs.mu() - gs.sigma()));
|
||||
}
|
||||
|
||||
let color = Palette99::pick(idx);
|
||||
|
||||
Reference in New Issue
Block a user