Skip to content

BUG: random: Fix check for both uniform variates being 0 in random_beta()#24204

Merged
charris merged 1 commit intonumpy:mainfrom
WarrenWeckesser:fix-beta-hang
Jul 18, 2023
Merged

BUG: random: Fix check for both uniform variates being 0 in random_beta()#24204
charris merged 1 commit intonumpy:mainfrom
WarrenWeckesser:fix-beta-hang

Conversation

@WarrenWeckesser
Copy link
Member

@WarrenWeckesser WarrenWeckesser commented Jul 17, 2023

The check for both uniform variates being 0 was using X + Y (which is U**(1/a) + V**(1/b)), instead of U + V. When a and b are both sufficiently small, it will be common for X + Y to be 0.

Closes gh-24203.

Copy link
Member

@rkern rkern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, from the comment and the subsequent check inside the if clause (which would be made irrelevant by the old version of the if test), I believe that is what was meant to be written.

@charris charris merged commit 26aef37 into numpy:main Jul 18, 2023
@charris
Copy link
Member

charris commented Jul 18, 2023

Thanks Warren.

@WarrenWeckesser WarrenWeckesser deleted the fix-beta-hang branch July 18, 2023 02:46
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.

BUG: random: beta (and therefore dirichlet) hangs when the parameters are very small.

3 participants