Skip to content

BUG: stats: don't emit invalid warnings if moments are infinite #7687

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

Merged
merged 1 commit into from
Jul 30, 2017

Conversation

pv
Copy link
Member

@pv pv commented Jul 30, 2017

Silence nan floating point warnings in rv_generic.stats, when
calculating derived values that may be nan if higher moments are
infinite.

This means calculations that do inf - inf or inf/inf.

Fixes the one crystalball moments failure currently on master.

Silence nan floating point warnings in rv_generic.stats, when
calculating derived values that may be nan if higher moments are
infinite.
@pv pv added the scipy.stats label Jul 30, 2017
@josef-pkt
Copy link
Member

Do you have a link to the test run to see which distributions this affects?

Distributions that have undefined (nan) or infinite theoretical moments should specify this in the distribution specific method.

If these are numerical problems like overflow, then maybe the examples should be adjusted.

(I don't remember anything about crystalball)

@pv
Copy link
Member Author

pv commented Jul 30, 2017

@pv
Copy link
Member Author

pv commented Jul 30, 2017

The distribution I think explicitly returns infinities from its _munp method as appropriate.
But stats() does further computations based on these values.

@josef-pkt
Copy link
Member

Ok, it would be possible to avoid computing g1 in the generic code if either m2 or m3 or both are inf or nan.
However that requires another lazywhere or similar while floating point computation with it produce the correct results with just the warning noise.

@pv
Copy link
Member Author

pv commented Jul 30, 2017

Yes, as far as I understand the produced results are reasonable, and it would be a bit fiddly to explicitly specify these when whether the moments exist depends on the parameters.

@ev-br
Copy link
Member

ev-br commented Jul 30, 2017

One could argue whether this should be fixed at the level of the concrete distribution (cf_lazywhere gymnastics at crystalball._munp). However this is a simpler fix, and in it goes.

@ev-br ev-br added this to the 1.0 milestone Jul 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants