Fernando Perez wrote:
> On 11/1/06, David Cournapeau <da...@ar...> 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 ;)
>
Ok, I deserve my email to be called the most stupid email of the week...
Sorry for the noise,
David
|