np.random contains two functions to generate random integers: randint and random_integers. Anyone know what the difference is without checking the docs...?
(randint treats its range as half-open [low, high) like other ranges in python; random_integers treats it as closed like [low, high].)
The Python stdlib is not much better, with randrange and randint, but at least randrange makes its semantics obvious from the name (it has the same semantics as the standard range function), and randint is a wart that predates randrange and survives for backwards compatibility.
For extra points, the mapping is:
Can we at least add a proper np.random.randrange function? (Extra points if we add support for the step argument at the same time; stdlib randrange supports this.) That's the key one we need to follow Python convention. And maybe we should deprecate our randint at the same time?
A related issue is that the docs for these functions could probably use some improvement:
random.random_integers : similar to `randint`, only for the closed
interval [`low`, `high`], and 1 is the lowest value if `high` is
omitted. In particular, this other one is the one to use to generate
uniformly distributed discrete non-integers. # <--- What does that mean?
To sample from N evenly spaced floating-point numbers between a and b,
a + (b - a) * (np.random.random_integers(N) - 1) / (N - 1.)
# I'm pretty sure everyone would just call `randint` instead of subtracting 1.
(followed by some example.)