Skip to content

Fix Distribution.cdf/ppf outside truncation limits - #608

Open
dweindl wants to merge 4 commits into
PEtab-dev:mainfrom
dweindl:fix_truncated_cdf
Open

dweindl wants to merge 4 commits into
PEtab-dev:mainfrom
dweindl:fix_truncated_cdf

Conversation

@dweindl

@dweindl dweindl commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

For truncated distributions, Distribution.cdf returned values below 0 or above 1 outside the truncation range. It now returns 0 below the lower and 1 at or above the upper truncation limit (also fixes cdf(trunc_high) being 1 - 1e-16).

Additionally:

  • For truncated distributions, ppf returns NaN for quantiles outside [0, 1], as in the untruncated case (previously returned finite values outside the truncation range).
  • pdf, cdf and ppf now consistently return NumPy scalars for scalar input and arrays for array-like input, matching the type annotations and scipy. Previously, depending on truncation and log-transformation, scalar input sometimes produced 0-d arrays.
  • pdf, cdf and ppf accept lists for all distributions.
  • For truncated distributions, pdf(nan) returns NaN instead of 0, as for untruncated distributions and scipy.

Fixes #602.

🤖 Generated with Claude Code

For truncated distributions, `cdf` returned values below 0 or above 1
outside the truncation range. It now returns 0 below the lower and 1 at
or above the upper truncation limit.

`ppf` of truncated distributions now returns NaN for quantiles outside
[0, 1], consistent with the untruncated case. `pdf`, `cdf` and `ppf` of
truncated distributions now also accept lists.

Fixes PEtab-dev#602.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov-commenter

codecov-commenter commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.11%. Comparing base (d7e9e98) to head (e50a5c2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #608      +/-   ##
==========================================
+ Coverage   80.03%   80.11%   +0.08%     
==========================================
  Files          70       70              
  Lines        8419     8424       +5     
  Branches     1541     1541              
==========================================
+ Hits         6738     6749      +11     
+ Misses       1189     1183       -6     
  Partials      492      492              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

dweindl and others added 3 commits November 17, 2026 22:34
Depending on truncation and log-transformation, these methods returned
either NumPy scalars or 0-d arrays for scalar input. They now
consistently return NumPy scalars for scalar input and arrays for
array-like input, matching the type annotations and scipy. Lists are now
accepted for all distributions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
For truncated distributions, `pdf(nan)` returned 0, because NaN failed
the truncation range check. It now returns NaN, as for untruncated
distributions and scipy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dweindl
dweindl marked this pull request as ready for review November 17, 2026 22:01
@dweindl
dweindl requested a review from a team as a code owner November 17, 2026 22:01
@dweindl dweindl self-assigned this Nov 18, 2026

This branch has not been deployed

No deployments
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.

Distribution.cdf returns values outside [0, 1] for truncated distributions

2 participants