fix: correct three distribution bugs and add CITATION.cff#25
Merged
Conversation
scipy.stats.triang expects its first argument (c) to be the normalized peak position in [0, 1], not the raw peak value. The raw peak c must be mapped to (c - a) / (b - a) before passing to triang. Closes #4
The old implementation used scipy.stats.exponweib (exponentiated Weibull), not the standard two-parameter Weibull distribution that the docstring and table describe. Switch to weibull_min(k, loc=0, scale=lamda) which matches the documented Weibull(lamda, k) parameterization. Closes #5
The previous call used loc=mu which shifts the distribution support in the original scale, not the log scale. The standard parameterization treats mu as E[ln(X)] (log-mean), so the correct scipy call is lognorm(sigma, loc=0, scale=exp(mu)) — the distribution's median is then exp(mu) as expected. Closes #3
GitHub surfaces CITATION.cff files automatically in the repository sidebar, making it easy for users to cite the software in academic work. Closes #8
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Fixes three long-standing bugs in the distribution constructors and adds a citation file.
Tri()triangular distribution —scipy.stats.triangexpects its first argument to be the normalized peak(c - a) / (b - a)in[0, 1], not the rawcvalue. Closes Bug in Tri() constructor for triangular distribution #4Weib()Weibull distribution — replacedexponweib(exponentiated Weibull) withweibull_min(k, loc=0, scale=lamda)which matches the documented two-parameter Weibull. Closes Weib distribution #5LogN()log-normal parameterization —loc=muwas wrong (shifts support in original scale); changed toloc=0, scale=exp(mu)somucorrectly means E[ln(X)]. Closes Add shape param for LogN distribution #3CITATION.cff— GitHub surfaces this in the sidebar for easy software citation. Closes Add CITATION.cff file #8Test plan
Tri(1, 5, 3).mean≈ 3.0 (peak at midpoint → symmetric → mean at midpoint)Weib(4, 6).mean≈scipy.stats.weibull_min.mean(c=6, scale=4)≈ 3.78LogN(0, 1).mean≈scipy.stats.lognorm.mean(1)≈ 1.649 (median = exp(0) = 1)🤖 Generated with Claude Code