Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Exponential distribution #325

Merged
merged 7 commits into from
May 15, 2024
Merged

[ENH] Exponential distribution #325

merged 7 commits into from
May 15, 2024

Conversation

ShreeshaM07
Copy link
Contributor

What does this implement/fix? Explain your changes.

This interfaces the Exponential distribution using the _ScipyAdapter.

Does your contribution introduce a new dependency? If yes, which one?

No

Did you add any tests for the change?

Yes

PR checklist

For all contributions

See here for full badge reference

  • The PR title starts with either [ENH], [MNT], [DOC], or [BUG]. [BUG] - bugfix, [MNT] - CI, test framework, [ENH] - adding or improving code, [DOC] - writing or improving documentation or docstrings.
For new estimators

@ShreeshaM07 ShreeshaM07 marked this pull request as draft May 14, 2024 12:48
def _get_scipy_object(self) -> rv_continuous:
return expon

def _get_scipy_param(self) -> dict:

Choose a reason for hiding this comment

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

return type here is a dict, but then you are returning a tuple composed of a list and a dict

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed the return type must be changed.


Parameter
---------
mu : float or array of float (1D or 2D)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would give this a single parameter, rate. The scipy parameter scale is then the inverse of rate.

Copy link
Contributor Author

@ShreeshaM07 ShreeshaM07 May 15, 2024

Choose a reason for hiding this comment

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

Yes that is correct I misunderstood the distrbution's parameter in scipy. It needs to be rate itself.

But I do not seem to understand how it would be able to do the shifting and scaling using loc and scale as they have described in the docs if I am only using the rate parameter.

The probability density above is defined in the “standardized” form. 
To shift and/or scale the distribution use the loc and scale parameters. Specifically, expon.pdf(x, loc, scale) is
identically equivalent to expon.pdf(y) / scale with y = (x - loc) / scale. Note that shifting the location of a distribution
does not make it a “noncentral” distribution; noncentral generalizations of some distributions are available in separate classes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest, let's use the same parameters as on wikipedia:

https://en.wikipedia.org/wiki/Exponential_distribution

We cannot use lambda as it is a reserved python keyword, so rate is the next best thing as it is consistent with Poisson process terminology.

@ShreeshaM07 ShreeshaM07 marked this pull request as ready for review May 15, 2024 08:59
@@ -21,12 +21,14 @@
"TDistribution",
"Uniform",
"Weibull",
"Exponential",
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you put this to be alphabetically ordered?

@@ -43,6 +43,7 @@ Continuous support
Normal
TDistribution
Weibull
Exponential
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you put this to be alphabetically ordered?

@fkiraly fkiraly changed the title [ENH] Interace Exponential distribution [ENH] Exponential distribution May 15, 2024
@ShreeshaM07
Copy link
Contributor Author

I've made the changes accordingly please let me know if anything else needs to be done. I shall create PR with the updated ngboost files as well.

Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

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

Looks good!

@fkiraly fkiraly merged commit 8bf1386 into sktime:main May 15, 2024
36 checks passed
@ShreeshaM07 ShreeshaM07 deleted the dev branch May 16, 2024 03:33
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.

3 participants