-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
BUG: stats.tukeylambda: Bad behavior of the cdf()
and sf()
methods in the tails.
#21370
Comments
Interesting catch! It seems Newton’s method may work for this problem and may consume fewer iterations, but a closer look is probably necessary to make sure it is robust for different inputs. |
I have a fix in progress. Currently I'm using the |
Btw, when |
@fancidev I noticed that too. In fact, it was while investigating that behavior that I ran into the loss of precision of I'm experimenting with a technique that gives good results over a wide range of λ, but I think it will be slow, even when implemented in C++. It will be part of the changes that I am working on for |
For For It remains to determine the domain of Wolfram Alpha suggests that an alternative first-order approximation for |
For where For The last term is evaluated using If
|
Describe your issue.
When
lam
< 0, asx
gets larger,tukeylambda.cdf(x, lam)
saturates at0.9999999999999929
instead of1
andtukeylambda.sf(x, lam)
levels off at7.105427357601002e-15
instead of decreasing to0
.tukeylambda.pdf(x, lam)
levels off at5.9894274089194295e-22
in the positive and negative tails.The source of the problem is in the bisection method that is used in
special.tklmbda
, which can be found in https://github.com/scipy/scipy/blob/main/scipy/special/xsf/cephes/tukey.h. That code needs to be refined.Reproducing Code Example
SciPy/NumPy/Python version and system information
The text was updated successfully, but these errors were encountered: