Skip to content

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

@WarrenWeckesser

Description

@WarrenWeckesser

Describe the issue:

The beta random variate generator hangs when the parameters a and b are both very small. Because dirichlet depends on the beta distribution, it also hangs when some or all values in alpha are very small.

Reproduce the code example:

rng = np.random.default_rng()
rng.beta(1e-49, 1e-40)               # hangs
rng.dirichlet([0.01, 1e-49, 1e-40])  # hangs

Error message:

No response

Runtime information:

In [5]: import sys, numpy; print(numpy.__version__); print(sys.version)
1.25.0rc1+520.gcd20fd045b
3.11.4 (main, Jul  3 2023, 14:49:40) [GCC 11.3.0]

In [6]: print(numpy.show_runtime())
[{'numpy_version': '1.25.0rc1+520.gcd20fd045b',
  'python': '3.11.4 (main, Jul  3 2023, 14:49:40) [GCC 11.3.0]',
  'uname': uname_result(system='Linux', node='pop-os', release='6.2.6-76060206-generic', version='#202303130630~1689015125~22.04~ab2190e SMP PREEMPT_DYNAMIC Mon J', machine='x86_64')},
 {'simd_extensions': {'baseline': [], 'found': [], 'not_found': []}},
 {'architecture': 'Zen',
  'filepath': '/usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so',
  'internal_api': 'openblas',
  'num_threads': 24,
  'prefix': 'libopenblas',
  'threading_layer': 'pthreads',
  'user_api': 'blas',
  'version': '0.3.20'}]
None

Context for the issue:

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions