-
-
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
DOC: clarify the definition of the pdf of stats.fisk
#14003
Conversation
This related to #13996 issue. |
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.
Thanks @Mazensayed91. Although per Matt's comment, we should switch the two formulas. Have the one without the minus as the default one.
Also there is a comment about this being also relevant for Burr. If this is correct, we could fix this here as well.
Made the positive formula as the default one, also added the same positive formula for Burr pdf
Thanks @tupui for the modifications, I've modified the request to fit them |
scipy/stats/_continuous_distns.py
Outdated
f(x, c, d) = c d x^{c - 1} / (1 + x^{c})^{d + 1} | ||
|
||
Also equivalent to: | ||
|
||
.. math:: | ||
|
||
f(x, c, d) = c d x^{-c - 1} / (1 + x^{-c})^{d + 1} |
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.
These two formulas are only equivalent for d=1
, i.e. for the fisk distribution.
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.
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 agree, looks like the first one is the right one. Also, if we're using LaTeX anyway, let's use \frac
and make it look identical to how the pdf is given on Wikipedia.
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.
It looks like the second one, the original one, is the intended one for the burr
distribution.
This is the PDF corresponding to the third CDF given in Burr's list;
specifically, it is equation (11) in Burr's paper [1]_
Taking the derivative and changing the symbols used for the parameters, it turns into:
This is what the code implements when x != 0
:
output = _lazywhere(x == 0, [x, c, d],
lambda x_, c_, d_: c_ * d_ * (x_**(c_*d_-1)) / (1 + x_**c_),
f2 = lambda x_, c_, d_: (c_ * d_ * (x_ ** (-c_ - 1.0)) /
((1 + x_ ** (-c_)) ** (d_ + 1.0))))
(I'll leave simplifying that to another time...)
It seems that the other one is burr12
.
stats.fisk
scipy/stats/_continuous_distns.py
Outdated
|
||
f(x, c) = c x^{c-1} (1 + x^{c})^{-2} | ||
|
||
Also equivalent to: |
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.
This is actually confusing, without reading the linked issue it was non-obvious that this wasn't a mistake. I suggest the following rephrase: Please note that the above expression can be transformed into the following one, which is also commonly used:
[skip azp] [skip actions]
In case others would like to check, here are comparisons of how the documentation now renders VS Wikipedia. FiskWikipedia (log-logistic distribution) Burr Type IIIWikipedia (Dagum distribution) It is not obvious how the CDF would turn into the PDF above or how the PDF shown here would be equivalent to the PDF in SciPy. (Sympy cannot confirm it, so I'm not even sure if the PDF on Wikipedia is correct.) But it is more obvious that the derivative of the CDF above, which is the same as that in Burr's paper, is equivalent to the PDF used in SciPy. from sympy import symbols, diff, simplify
x, a, p, c, d = symbols('x, a, p, c, d', real=True, positive=True)
F = (1 + x**(-a))**(-p) # Wikipedia CDF
f = diff(F, x).subs(a, c).subs(p, d) # Wikipdia deriviative of CDF, SciPy Notation
f_s = c*d*(x**(-c-1))/(1+x**(-c))**(d+1) # SciPy PDF
print(simplify(f - f_s)) # 0 Burr Type XIIWikipedia ("Burr Distribution") I see that it says I'm going to go ahead and merge this, but please let me know if you notice anything that the updates did not catch. |
Thanks @Mazensayed91 and reviewers! |
Reference issue
What does this implement/fix?
Additional information