[SciPy-Dev] numpy.random.* call convention

Robert Rehammar robert.open at rehammar.se
Thu Jun 7 01:24:43 EDT 2018


Dear num-py developers,

For the methods in numpy.random, the distributions typically have the 
signature (a, b, ...[, size]). a, b, ... are parameters to the 
distributions and size is optional that can be used to control how may 
samples to draw and the shape of the returned structure. The parameters 
can also be array_like to draw from different (parametrized) distributions.

However, it is not what I can see, possible to have the parameters 
array_like and at the same time use size!=None. It would be desirable to 
be able to have that. Some different conventions could be used, e.g. the 
returned structure res could be

res.shape == a.shape + size.shape

or the distributions could require that the first dimensions of size 
should be the same as a.shape. (I guess a.shape == b.shape = ...)

This all would allow me to generate more random samples in one go. Any 
thoughts on that? Adding this feature would not break compatibility 
since it is just allowing additional parameter combinations to the 
distributions. Legacy code will function the same.

Best,

Robert



More information about the SciPy-Dev mailing list