Skip to content

The arguments of randint() and random_integers() do not broadcast. #6745

@WarrenWeckesser

Description

@WarrenWeckesser

(This is either a request for an enhancement, or a bug report--take your pick.)

Unlike most of the other distributions implemented in the RandomState class, randint and random_integers do not broadcast their arguments.

For example, hypergeometric broadcasts:

In [87]: rng = np.random.RandomState()

In [88]: rng.hypergeometric(10, [10, 20, 30], 10)
Out[88]: array([6, 2, 1])

But randint only accepts scalar integers:

In [89]: rng.randint(10, [10, 100])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-89-b14fbd2d38cb> in <module>()
----> 1 rng.randint(10, [10, 100])

mtrand.pyx in mtrand.RandomState.randint (numpy/random/mtrand/mtrand.c:9556)()

TypeError: an integer is required

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