Skip to content

[ENH] Exponential distribution#325

Merged
fkiraly merged 7 commits into
sktime:mainfrom
ShreeshaM07:dev
May 15, 2024
Merged

[ENH] Exponential distribution#325
fkiraly merged 7 commits into
sktime:mainfrom
ShreeshaM07:dev

Conversation

@ShreeshaM07

Copy link
Copy Markdown
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
Comment thread skpro/distributions/exponential.py Outdated
def _get_scipy_object(self) -> rv_continuous:
return expon

def _get_scipy_param(self) -> dict:

Copy link
Copy Markdown

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
Copy Markdown
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.

Comment thread skpro/distributions/exponential.py Outdated

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

Copy link
Copy Markdown
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.

@ShreeshaM07 ShreeshaM07 May 15, 2024

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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
Comment thread skpro/distributions/__init__.py Outdated
"TDistribution",
"Uniform",
"Weibull",
"Exponential",

Copy link
Copy Markdown
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?

Normal
TDistribution
Weibull
Exponential

Copy link
Copy Markdown
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
Copy Markdown
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.

@fkiraly fkiraly left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good!

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