numpy.random.ranomd_integers returning only negative numbers ?

Fernando Perez fperez.net at gmail.com
Thu Nov 2 00:25:57 EST 2006


On 11/1/06, David Cournapeau <david at ar.media.kyoto-u.ac.jp> wrote:
> Hi,
>
>     I want to generate some random integers,let's say in the range [-
> 2^15, 2^16]. Why doing:
>
>     noise = numpy.random.random_integers(- (2 ** 15), (2 * 15), 22050)
>
>     gives only negative numbers ?

In [3]: noise = numpy.random.random_integers(- (2 ** 15), (2 * 15), 22050)

In [4]: noise[noise>0].shape
Out[4]: (17,)

In [5]: noise[noise<0].shape
Out[5]: (22033,)

In [6]: noise = numpy.random.random_integers(-(2**15), (2 ** 15), 22050)

In [7]: noise[noise>0].shape
Out[7]: (11006,)

In [8]: noise[noise>0].shape
Out[8]: (11006,)

In [9]: 17./22033
Out[9]: 0.00077156991785049694

In [10]: 2.0*15/2**15
Out[10]: 0.00091552734375

close enough ;)

Cheers,

f

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642




More information about the NumPy-Discussion mailing list