[SciPy-user] Random number generation and scipy.stats

John Hunter jdh2358 at gmail.com
Thu Mar 8 11:43:25 EST 2007


On 3/8/07, Anne Archibald <peridot.faceted at gmail.com> wrote:
> Hi,
>
> scipy.stats defines a number of distribution objects (scipy.stats.chi2
> represents the chi-squared distribution, for example). How useful
> would it be to add a .generate(size=(1,)) method which generated
> random numbers according to the distribution? There's practically no
> extra effort involved for those functions which have a .ppf() method,
> since that allows one to use the transformation method:

Isn't this what rvs already does, or am I misunderstanding you


In [184]: import scipy.stats as stats

In [185]: stats.expon(0,5).rvs(10)
Out[185]:
array([  6.49235468,   3.66423025,  11.22019501,   4.50247735,
         0.95703071,   4.67328849,   1.52512936,  22.77158456,
         7.32379865,   4.45632927])


JDH



More information about the SciPy-User mailing list