Hi fellow Perl users!

The rand() function as implemented in RISC OS Perl 1.13 for
the RiscPC is *not* uniform as it should be.

Some time ago, when I was experimenting with this, I wrote
the attached program to demonstrate the problem but it's
just dawned on me that I never even mentioned this problem
to the mailing list. So here I am doing just that.

The attached program should not be run in a task window
because it needs to be able to change mode and plot a
probability distribution graph. If you run it you will
notice that values in the middle of rand's range are far
less likely to occur than values at either end.

Another thing I've noticed is that the rate of change in the
probability appears to be linear in the lower half of the
range and non-linear in the upper half. Weird eh?

Does anyone (Nick?) know why rand has this behaviour
or, even better, know how to fix it?

PS. I tried writing my own random number generator in Perl
but, although it works and is uniform, it is unfortunately
really quite slow. If anyone's interested, I can post it.

-- 
James Taylor <[EMAIL PROTECTED]>
Based in Southam, Cheltenham, UK.
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02

Attachment: DispRand,102
Description: application/riscos

Reply via email to