You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exponential Cdf/Quantile lose all precision near zero: Exponential(2).Cdf(1e-17) = 0 and Quantile(1e-17) = −0 (expected 2e-17 and 5e-18) #52
For small arguments the relative error is about eps/x. Below ~1e-16 the result is 0, and the quantile even comes back as negative zero, outside the support.
These are the textbook expm1/log1p cases. The file's own SurvivalFunction remark explains why subtracting from one rounds tails away, but the lower tail (Cdf) and Quantile don't get the same treatment. Small-probability quantiles, for example "time by which 1-in-a-billion events have happened", come out wrong or as −0.
Suggested fix
Cdf = -expm1(-Rate * x) and Quantile = -log1p(-p) / Rate, using accurate helpers. .NET's double.ExpM1/LogP1 are naive, so these belong in SpecialFunctions, shared with the Geometric fix filed alongside this issue.
Acceptance: both repro values match to ~1e-15 relative, and Quantile never returns −0.
Priority: Low. Precision is lost only for arguments below about 1e-10 (the result becomes 0 or −0 below about 1e-16). The results are wrong, but only in a narrow regime.
Area / suggested owner: Essentials distributions, ExponentialDistributionProvider (Cdf, Quantile), plus SpecialFunctions
Activity
matt-edmondson commentedon Sep 28, 2026
Triage
ExponentialDistributionProvider(Cdf,Quantile), plusSpecialFunctionsExpM1/Log1Phelpers inSpecialFunctions, so land that helper once and fix both.Next step: Add the helpers, then switch to
Cdf = -expm1(-λx)andQuantile = -log1p(-p)/λ, with tests for the repro values and for never returning −0.Generated by Claude Code