It seems that rand function doesn't accept arguments greater than 32768. Or, more precisely, it treats any larger number as this one. Very confusing. More than, (rand n) seems to be implemented as (% (rand 32768) n), which is good for big ranges, but is a very poor solution for a 15-bit range. (E.g. average of a million (rand 10000) samples is 4650, not 5000). In fact I have a bad feeling that the random number generator used in newLISP has much more sins which made it really unusable. Now I am trying to rewrite random.py module from the standard Python library to newLISP. It has rather good reputation.
P.S. I am using Win32 port of newLISP, maybe other platforms have better random numbers.
Random numbers
Random numbers
With newLISP you can grow your lists from the right side!
The next development 9.2.6 version will have better integer random number generation with 'rand' on Win32.
As a workaround on the current versions use 'random' instead of 'rand' and put an 'int' wrapper around it:
Lutz
As a workaround on the current versions use 'random' instead of 'rand' and put an 'int' wrapper around it:
Code: Select all
(map int (random 0 10 20))
=> (3 5 5 4 6 0 5 7 3 9 5 8 7 6 0 7 8 9 8 8)