[SciPy-user] strange behavior in RandomArray.randint()

Tom Denniston tom.denniston at gmail.com
Thu May 19 16:00:39 EDT 2005


I am running under python 1.4 and windows XP.
I get the following results in my python interpretter:


--------------------------------------------
n=0
import RandomArray
while 1:
	arr = RandomArray.randint(0, 2509, 252)
	for x in arr:
		if x>2508:
			raise "Found number greater than 2508: " + str(x) + " on iteration " + str(n)
	n=n+1

	

Traceback (most recent call last):
  File "<pyshell#43>", line 5, in -toplevel-
    raise "Found number greater than 2508: " + str(x) + " on iteration
" + str(n)
Found number greater than 2508: 2509 on iteration 91719

-------------------------------------------

Even though the Numeric reference (see below) on RandomArray class
claims that the number is strictly less than the max.  Does anyone
know what might cause this problem.  Does SciPy have an alternative
approach to generating uniform random numbers that is more reliable?

randint(minimum, maximum, shape=ReturnFloat) 
The randint() function returns an array of the specified shape and
containing random (standard) integers greater than or equal to minimum
and strictly less than maximum . If no shape is specified, a single
number is returned. (exerpt from
http://www.pfdubois.com/numpy/html2/numpy-19.html#pgfId-303108)




More information about the SciPy-User mailing list