Skip to content

fix: NormalDist.log_pdf divide SD by sqrt(weights) instead of weights#458

Open
DEEP-600 wants to merge 2 commits intodswah:mainfrom
DEEP-600:fix/normal-log-pdf-weights
Open

fix: NormalDist.log_pdf divide SD by sqrt(weights) instead of weights#458
DEEP-600 wants to merge 2 commits intodswah:mainfrom
DEEP-600:fix/normal-log-pdf-weights

Conversation

@DEEP-600
Copy link

@DEEP-600 DEEP-600 commented Feb 24, 2026

NormalDist.log_pdf was dividing SD by weights instead of sqrt(weights), making the effective variance scale² / w² instead of scale² / w. This disagrees with the GLM convention used by V(), phi(), and _W() throughout the codebase.

Change: self.scale / weightsself.scale / np.sqrt(weights) (one line in distributions.py)

Tests: Added test_distributions.py with 4 tests — weights=1, weights>1, vectorized, and None default. Full suite passes (153 passed, 0 failures).

Impact: Fixes log-likelihood and downstream stats (AIC, AICc, GCV, pseudo R²) for LinearGAM with non-uniform sample weights. Fitted coefficients are unaffected since PIRLS uses V() and _W() which were already correct.

Fixes #457

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] - NormalDist.log_pdf applies weights to standard deviation instead of variance

1 participant