[Coco] Tandy Color Computer 3 RND Function
William Astle
lost at l-w.ca
Thu Mar 26 13:39:41 EDT 2020
On 2020-03-26 11:09 a.m., Arthur Flexser wrote:
> But, I wonder if a truly random function would pass
> this test?: There might well be some bunching of points purely due to
> chance, with a finite number of dots. Just like with random coin flips
> generating apparently long runs of heads or tails every now and then.
This is exactly right. Randomness is lumpy. Something that is truly
random with equal probability for all outcomes will eventually arrive at
a basically uniform distribution, but that requires a very large number
of data points for that pattern to start to emerge and it's very
unlikely that you will get a truly uniform distribution even then
compared to something with at least a tiny bit of variation. (If you
play around with calculating the relative probabilities, you may be able
to convince yourself of that.)
If you run a relatively small number of tests and get a uniform
distribution, then you don't have a good random number source. It really
should be lumpy. It *feels* more random to many of us if we see a
uniform distribution, but it really isn't.
All that said, RND() is a *pseudo* random number generator and is
completely deterministic. That means if you run through its period (how
long before the sequence repeats), you may not end up with an even
distribution. In fact, you probably don't. Different pseudo-random
generators have different characteristics. I don't know how good the
algorithm used by RND() actually is, but for a great many things, it's
good enough, especially if you can seed it with something a bit random
so you don't know where in the sequence you're starting.
Note that its range is a great deal larger than the 10 bits needed to
get to 640 so you'll probably get better overall randomness with 10 bit
values than you will using the entire range (probably 32 bits, actually,
given the mantissa size of floating point numbers in Color Basic).
More information about the Coco
mailing list