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

Log Cdf of GenExtreme outputs negative infinity instead of zero at extreme right #349

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

souvikpaul33
Copy link

Adding a change to gev logcdf

@souvikpaul33
Copy link
Author

pull req first time

@ricardoV94
Copy link
Member

Did you close by accident @souvikpaul33 ?

@souvikpaul33
Copy link
Author

@ricardoV94 I think yes. Sorry for that. I'm reopening it.

@souvikpaul33 souvikpaul33 reopened this Jun 17, 2024
@ricardoV94
Copy link
Member

CC @ccaprani if you want to review

@ricardoV94
Copy link
Member

@souvikpaul33 can you rename the PR title to be more informative (we use it for the release notes). And can you add a test that covers the previously broken functionality?

@souvikpaul33 souvikpaul33 changed the title Souvik Log Cdf of GenExtreme outputs negative infinity instead of zero at extreme right Jul 16, 2024
@souvikpaul33
Copy link
Author

souvikpaul33 commented Jul 16, 2024

@souvikpaul33 can you rename the PR title to be more informative (we use it for the release notes). And can you add a test that covers the previously broken functionality?

@ricardoV94 Thanks! Renamed the title.

This is the example test case where it was broken before

import numpy as np
import pymc as pm
import pymc_experimental.distributions as pmx

rv = pmx.GenExtreme.dist(mu=0, sigma=1, xi=-0.5) # range of x: (-inf, 2)
x = np.array([-100,-50,-40, -30, -10,-5,-2,-1,0,1,1.5,1.7,1.9,1.99,2,3,4,5]) # check last four values : extreme right
lcdf_gev = pm.logcdf(rv, x)
print(x) # check last four values : extreme right
[-100. -50. -40. -30. -10. -5. -2. -1. 0. 1.5 1.7 1.9 1.99 2. 3. 4. 5. ]
print(lcdf_gev.eval()) # check last four values : extreme right
[-2.601e+03 -6.760e+02 -4.410e+02 -2.560e+02 -3.600e+01 -1.225e+01 -4.000e+00 -2.250e+00 -1.000e+00 -2.500e-01 -6.250e-02 -2.250e-02 -2.500e-03 -2.500e-05 -inf -inf -inf -inf]

print(np.exp(lcdf_gev.eval())) # check last four values : extreme right
[0.00000000e+000 2.61174176e-294 2.99318445e-192 6.61626106e-112 2.31952283e-016 4.78511739e-006 1.83156389e-002 1.05399225e-001 3.67879441e-001 7.78800783e-001 9.39413063e-001 9.77751237e-001 9.97503122e-001 9.99975000e-001 0.00000000e+000 0.00000000e+000 0.00000000e+000 0.00000000e+000]

Screenshot 2024-06-06 115109

@ricardoV94
Copy link
Member

It should be enough to test one of the last values that was giving -inf. You'll have to add the check as a test in the codebase

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.

2 participants