[Numpy-discussion] Specifying a dtype with RandomState?

alexwphoto@gmai... alexwphoto@gmai...
Wed Dec 24 16:11:13 CST 2008


I'm generating rather large matrices with a fixed random seed using

rs = N.random.RandomState(123456789)
U = rs.uniform(low=-0.1 high=self.0.1 size=(480189, 1000)).astype('float32')
...
Several other arrays are instantiated as well.
Because they are so large, I do all calculations on single-precision arrays.

Coercing the output of rs.uniform() into a float32 requires an enormous copy
operation (if I understand right). Since I am already hitting the upper
limit of the memory space I have, it would be convenient if I could avoid
the astype('float32') operation.

Is there a way to have a RandomState object output single-precision floats?

Thanks,
Alex W
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20081224/71f4cb8a/attachment.html 


More information about the Numpy-discussion mailing list