[Numpy-discussion] random integers

Ralf Gommers ralf.gommers at gmail.com
Thu Dec 31 02:01:59 EST 2015

On Thu, Dec 31, 2015 at 6:31 AM, Charles R Harris <charlesr.harris at gmail.com
> wrote:

> Hi All,
> I've implemented several new random integer functions in #6910
> <https://github.com/numpy/numpy/pull/6910>, to wit
>    - np.random.random_int32
>    - np.random.random_int64
>    - np.random.random_intp
> These are the minimum functions that I think we need for the numpy 1.11.0
> release, most especially the random_intp function for fuzz testing the
> mem_overlap functions. However, there is the question of the best way to
> expose the functions. Currently, they are all separately exposed, but it
> would also be possible to expose them through a new dtype argument to the
> current np.random.random_integers function. Note that all all the new
> functions would still be there, but they could be hidden as private
> functions. Also, there is the option of adding a complete set comprising
> booleans, int8, int16, and the unsigned versions. So the two, not mutually
> exclusive, proposed enhancements are
>    - expose the new functions through a dtype argument to
>    random_integers, hide the other functions
+1 for a single new keyword only and hiding the rest. There's already
random.randint and random.random_integers (keyword should be added to both
of those). That's already one function too many. Adding even more functions
would be very weird.

>    -
>    - expose the new functions through a dtype argument to
>    random_integers, not hide the other functions
>    - make a complete set of random integer types
> There is currently no easy way to specify the complete range, so a
> proposal for that would be to generate random numbers over the full
> possible range of the type if no arguments are specified. That seems like a
> fairly natural extension.

I don't understand this point, low/high keywords explicitly say that they
use the full available range?

> Finally, there is also a proposal to allow broadcasting/element wise
> selection of the range. This is the most complicated of the proposed
> enhancements and I am not really in favor, but it would be good to hear
> from others.
I don't see much of a use-case. Broadcasting multiple keywords together is
tricky to implement and use. So for the few users that may need this, a
small for loop + array stack should get their job done right?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20151231/6eb99efa/attachment.html>

More information about the NumPy-Discussion mailing list