[Numpy-discussion] in place random generation

Timothy Hochberg tim.hochberg at ieee.org
Wed Mar 7 16:51:23 EST 2007


On 3/7/07, Robert Kern <robert.kern at gmail.com> wrote:
>
> Daniel Mahler wrote:
> > Is there an efficient way to fill an existing array with random
> > numbers without allocating a new array?
>
> No, sorry.


There is however an only moderately inefficient way if you are primarily
concerned with keeping your total memory usage down for some reason. In that
case, you can fill your array in chunks; for example getting 1000 random
numbers at a time from random.random and successively copying them into your
array. It's probably not worth the trouble unless you have a really big
array though.


-- 

//=][=\\

tim.hochberg at ieee.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20070307/1c35ca51/attachment.html>


More information about the NumPy-Discussion mailing list