[vcf-midatlantic] Random numbers
evan at vcfed.org
Fri Apr 7 13:33:24 EDT 2017
> I don't know why the result is always an even number, but I suspect that this will always return the same sequence of numbers. You have to randomize the seed value of the argument to the rnd function early in the program or it will return the same sequence of numbers every time you turn the machine on.
> From http://www.hoist-point.com/applesoft_basic_tutorial.htm#random_numbers_section
> AppleSoft BASIC RND(1) function generates a pseudo-random number between 0 and 1 (excluding 1). Random numbers are used in games, computer modeling and math applications. Let's look at small program which simulates throwing a dice 20 times, generating values from 1 to 6, and prints the result.
> As you run this program again and again, you notice that it generates exactly the same set of numbers every time. The numbers you get from RND(1) function aren't truly random (this is why they are called pseudo-random!): computer uses an algorithm to generate them, and when program restarts, the same algorithm produces the same sequence of values. To make it generate a new sequence, you must re-initialize the random number generator by calling RND with a negative value (called random seed). Each specific value will result in different random number sequence generated afterwards.
Interesting! Thanks for the link.
True randomness probably doesn't matter to this program because -- yet
again -- it's just for children and the set from 1-38 is big enough that
most people will not notice any trends.
I've to solve the even numbers mystery.
More information about the vcf-midatlantic