Skip to content

fix: correct three distribution bugs and add CITATION.cff#25

Merged
saudzahirr merged 5 commits into
masterfrom
fix/distribution-bugs
May 19, 2026
Merged

fix: correct three distribution bugs and add CITATION.cff#25
saudzahirr merged 5 commits into
masterfrom
fix/distribution-bugs

Conversation

@saudzahirr

@saudzahirr saudzahirr commented May 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes three long-standing bugs in the distribution constructors and adds a citation file.

  • Fix Tri() triangular distributionscipy.stats.triang expects its first argument to be the normalized peak (c - a) / (b - a) in [0, 1], not the raw c value. Closes Bug in Tri() constructor for triangular distribution #4
  • Fix Weib() Weibull distribution — replaced exponweib (exponentiated Weibull) with weibull_min(k, loc=0, scale=lamda) which matches the documented two-parameter Weibull. Closes Weib distribution #5
  • Fix LogN() log-normal parameterizationloc=mu was wrong (shifts support in original scale); changed to loc=0, scale=exp(mu) so mu correctly means E[ln(X)]. Closes Add shape param for LogN distribution #3
  • Add CITATION.cff — GitHub surfaces this in the sidebar for easy software citation. Closes Add CITATION.cff file #8

Test plan

  • Tri(1, 5, 3).mean ≈ 3.0 (peak at midpoint → symmetric → mean at midpoint)
  • Weib(4, 6).meanscipy.stats.weibull_min.mean(c=6, scale=4) ≈ 3.78
  • LogN(0, 1).meanscipy.stats.lognorm.mean(1) ≈ 1.649 (median = exp(0) = 1)
  • CITATION.cff appears in GitHub sidebar

🤖 Generated with Claude Code

saudzahirr and others added 5 commits May 19, 2026 23:25
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>
@sonarqubecloud

Copy link
Copy Markdown

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
soerp/distributions.py 25.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@saudzahirr saudzahirr merged commit 8e48702 into master May 19, 2026
14 checks passed
@saudzahirr saudzahirr deleted the fix/distribution-bugs branch May 19, 2026 18:41
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.

Add CITATION.cff file Weib distribution Bug in Tri() constructor for triangular distribution Add shape param for LogN distribution

2 participants