[Numpy-discussion] Another Array

Ian Mallett geometrian at gmail.com
Fri Apr 10 03:07:45 EDT 2009


This seems to work:

vecs = Numeric.random.standard_normal(size=(self.size[0],self.size[1],3))
magnitudes = Numeric.sqrt((vecs*vecs).sum(axis=-1))
uvecs = vecs / magnitudes[...,Numeric.newaxis]
randlen = Numeric.random.random((self.size[0],self.size[1]))
randuvecs = uvecs*randlen[...,Numeric.newaxis]
rgb = ((randuvecs+1.0)/2.0)*255.0

(I have "import numpy as Numeric" for other reasons, that's why there's
Numeric there).

Thanks,
Ian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20090410/84e6aaa1/attachment.html>


More information about the NumPy-Discussion mailing list