[Numpy-discussion] in place random generation

Timothy Hochberg tim.hochberg@ieee....
Wed Mar 7 15:51:23 CST 2007


On 3/7/07, Robert Kern <robert.kern@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@ieee.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070307/1c35ca51/attachment.html 


More information about the Numpy-discussion mailing list