[vcf-midatlantic] Random numbers
chrisjpf33 at gmail.com
Fri Apr 7 19:22:18 EDT 2017
Is the random number generator running by itself or within the rest of your program? I just ran your formula in an infinite loop to print the results and I get even and odd numbers. Perhaps the other part of the program is performing a calculation that makes it even. I did it on a Commodore but it is the same code.
> On Apr 7, 2017, at 1:33 PM, Evan Koblentz via vcf-midatlantic <vcf-midatlantic at lists.vintagecomputerfederation.org> wrote:
> 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