user67275
user67275

Reputation: 2170

numpy randint arguments exclusive

In the official NumPy documentation, numpy.random.randint has an exclusive second argument.

random.randint(low, high=None, size=None, dtype=int)
    Return random integers from low (inclusive) to high (exclusive).

Then, I thought random.randint(1, 5) returns values 1, 2, 3, or 4, but it actually gives values among 1, 2, 3, 4, and 5.

What went wrong?

Upvotes: 2

Views: 462

Answers (1)

BrokenBenchmark
BrokenBenchmark

Reputation: 19242

You’re conflating numpy.random.randint with Python’s random.randint (from the random module in the standard library), the latter of which has an inclusive upper bound.

Upvotes: 4

Related Questions