[Numpy-discussion] ndarray.count() ?

Robert Kern robert.kern at gmail.com
Thu Sep 7 17:57:00 CDT 2006


rex wrote:
> Charles R Harris <charlesr.harris at gmail.com> [2006-09-07 15:04]:
>> I don't know about count, but you can gin up something like this
>>
>> In [78]: a = ran.randint(0,2, size=(10,))
>>
>> In [79]: a
>> Out[79]: array([0, 1, 0, 1, 1, 0, 0, 1, 1, 1])
> 
> This exposed inconsistent randint() behavior between SciPy and the Python
> random module. The Python randint includes the upper endpoint. The SciPy
> version excludes it.

numpy.random.random_integers() includes the upper bound, if you like. 
numpy.random does not try to emulate the standard library's random module.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco





More information about the Numpy-discussion mailing list