-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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: stats: Crystalball distribution #6798
Conversation
One issue with tests which fail is that higher moments do not exist for n=3. |
I'm working on the _munp implementation, Calculating the formulas using mathematica was easy, but there are numerical instabilities and odd definitions of the functions which are required to calculate the n-th moment (e.g. hyp2f1). So if munp is required I will need some more time (maybe I find some time next weekend to dive deeper into the mathematics behind hyp2f1). |
From a 10000 feet: Mathematica likes to express things in terms of hyp2f1, even if there's a simpler expression available (or at least it did in version 3 or something). Moments can be left for later I think. |
832ec2c
to
3a38729
Compare
Fixed merge conflicts. @ev-br |
scipy/stats/_continuous_distns.py
Outdated
|
||
%(example)s | ||
""" | ||
def _pdf(self, x, alpha, n): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe better use some other variable name, #5982
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed alpha to beta and n to m.
scipy/stats/_continuous_distns.py
Outdated
N = 1.0 / (n/alpha / (n-1) * np.exp(-alpha**2 / 2.0) + _norm_pdf_C * _norm_cdf(alpha)) | ||
return N * _lazywhere(np.atleast_1d(x > -alpha), (x, alpha, n), | ||
f = lambda x, alpha, n: np.exp(-x**2 / 2), | ||
f2 = lambda x, alpha, n: (n/alpha)**n * np.exp(-alpha**2 / 2.0) * (n/alpha - alpha - x)**(-n)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line way too long, here and elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored the lazywhere and introduced a right-hand-side (rhs) and left-hand-side (lhs)
lambda function which is passed to f and f2 of _lazywhere.
The lines are now shorter.
…nflicts with other scipy functions. Additionally, shortened some lines
Ping. I fixed the latest merge conflicts, are there further suggestions or comments to this PR? |
Pong? |
Hello, this is my bi-monthly reminder for this PR. |
Looks good to me now. Thanks, merging! |
Some issues remaining: gh-7687 |
The crystalball function is used in high-energy physics to parametrize data.
It is basically a Gaussian with a one-sided power-law tail.
https://en.wikipedia.org/wiki/Crystal_Ball_function
This is a split of, of another PR which contained several other distributions #6795