Skip to content

[Distributions] Implement Expon distribution#1

Merged
forfudan merged 8 commits intomojomath:mainfrom
shivasankarka:distributions
Mar 4, 2026
Merged

[Distributions] Implement Expon distribution#1
forfudan merged 8 commits intomojomath:mainfrom
shivasankarka:distributions

Conversation

@shivasankarka
Copy link
Copy Markdown
Member

@shivasankarka shivasankarka commented Mar 3, 2026

Exponential Distribution

This PR introduces an implementation of the continuous exponential distribution, Expon.

The implementation supports the standard parameterisation with loc and scale (fields of Expon) enabling shifting and scaling of the exponential distribution.

Traits

This PR also introduces a new trait, RVContinuousLike, designed to parameterise continuous probability distributions (to mimic scipy.stats.rv_continous). At present, the trait defines only the core functionality common to continuous random variables. Expon is the first distribution to conform to this trait. Support will be extended to additional continuous distributions in subsequent PRs.

@shivasankarka
Copy link
Copy Markdown
Member Author

@forfudan Please check if the format, method names etc look good and if I need to make any other changes. I tried to follow scipy.stats naming conventions and API wherever possible to keep it consistent. If everything looks good, I will open PR for the other distributions. Thanks!

@shivasankarka shivasankarka requested a review from forfudan March 3, 2026 07:24
Copy link
Copy Markdown
Member

@forfudan forfudan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shivasankarka I did some changes to your PR and merged it.

  1. Expon → Exponential, to be more self-explanatory as other distributions.
  2. RVContinuousLike → ContinuouslyDistributed, same as above, this is a not-so-pretty name of scipy (C-style)
  3. Remove the Copyable and Movable trait from Exponential because the ContinuouslyDistributed trait alreay contains them.
  4. Remove some unused imports.
  5. For logcdf, use log(-expm1(-y)) instead of log1p(-exp(-y)) for better stability when x -> loc.

@forfudan forfudan merged commit 9f9d7a0 into mojomath:main Mar 4, 2026
1 check passed
@shivasankarka shivasankarka deleted the distributions branch March 5, 2026 02:45
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.

2 participants