8000 Incorrect nan handling in multiple random generators · Issue #13283 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
Incorrect nan handling in multiple random generators #13283
@bashtage

Description

@bashtage

Many distributions accept nans but do not produce correct results.

np.random.vonmises(1., np.nan) goes into an infinite loop
np.random.geometric(np.nan) returns np.iinfo(np.int).min
np.random.poisson(np.nan) returns 0
np.random.negative_binomial returns 0
np.random.logseries returns 2
np.random.noncentral_f(1.0, 2.0, np.nan)' returns the same as np.random.noncentral_f(1.0, 2.0, 1.)since it relies onpoissonwhich returns0`.

Fixing most of these to raise would probably be OK. The only one that is tricky is noncentral_f which needs a nan-guard inserted at the bottom of the rk_noncentral_f so that the stream is preserved (it essentially draws non-sense values and then returns nan`.

Probably not worth fixing these now. They have been fixed in #13163. Related to #13189 since fixing this issue lead to this discovery. That issue is also fixed in #13163, although there is no test for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0