I can hear the cheering from here - the last TiGM Homework for this term! I understand... which is why I've made this one a little different. We are going to talk about generating random numbers on the calculator. In my experience, this is one of the functions that gets the most 'uh-ha's! I think it is because it is so dynamic and every calculator generates its own set of random numbers, yet there are similarities between them. Perhaps the most common use you'll find for the random generator is to simulate rolling a die, or tossing a coin.
Lesson 5
The first part of this lesson is going to explain how the calculator generates the numbers. The middle section will talk about some commands you need to understand and the last part will walk you through the steps to generate a certain range of numbers.
Part 1 - Pseudo-random numbers
The calculator is not able to produce truly random numbers, but instead generates pseudo-random numbers. To be very brief, the calculator substitutes a number (called a seed) into an algorithm and produces a long string of numbers.
Characteristics of a good algorithm include (source: HowStuffWorks.com):
- No repetition: The sequence does not cycle around and repeat itself.
- Good numeric distribution: If the formula is producing random numbers between 0 and 9, the number of zeros, ones, twos, etc. that it produces should be roughly equal over a long period of time.
- Lack of predictability: You have no way of predicting what the next number will be, unless you know the formula and the seed (the initial value).
Careful mathematical analysis is required to ensure that the generated numbers are sufficiently "random"; as Robert R. Coveyou of Oak Ridge National Laboratory once titled an article, "The generation of random numbers is too important to be left to chance" (source: Wikipedia.com).
Part 2 - Generating a random number
It takes some thought and time to get your brain around this next part, so I will take you through it step by step. Let's start off by seeing the random generator in action.
Turn your calculator on and enter RUN mode (figure 1). The command for 'random number' is not on your keypad (like so many other commands). You need to press the OPTN (option) key - or as Anthony Harradine calls it, 'where in the hell is it' key . This is located just right of your SHIFT button. Press OPTN and you will see a menu appear at the bottom of the screen (figure 2). Press 'des' (F6) and you will see PROB (F3) (figure 3). Enter the PROB menu and you will see Ran# (F4) (figure 4). Now press Ran# and then EXE several times. You will notice that random numbers have been produced (figure 5). I'm sure it will not generate the same numbers as mine, but if it does, email me immediately and buy yourself a Lotto ticket!
OPTN des (F6) PROB (F3) Ran# (F4)
You may have guessed that the random numbers range from 0 to 0.999... At the moment, this is only somewhat useful. I will now demonstrate another command that is useful to generate certain numbers.
Part 3 - Using the INT command
There is another command we will use often with random numbers. It is called INT (integer) and is found by going:
OPTN des (F6) NUM (F4) Int (F2)
Obviously, if you were still in the PROB menu from Part 2, then you can just press EXIT and then enter NUM from there. Beware, DO NOT use Intg,always use Int.
Let's see what this INT command does. Enter INT (F2), then 5.8 and press EXE (figure 6). You will notice the answer is 5 and that INT does not round the number up but simply truncates the decimals. Try a few more numbers if you'd like.
Part 4 - Generating a certain range of numbers
Okay, let's start putting the INT and Ran# together, to simulate rolling a die. This means generating integers 1 to 6.
Let's go through the theory first, step-by-step by talking about all the values possible:
- Ran# generates numbers 0 to 0.999....
- 6Ran# (6 times Ran#) generates numbers 0 to 5.999....
- Int(6Ran#) generates integers 0, 1, 2, 3, 4 and 5
- Int(6Ran#)+1 generates integers 1, 2, 3, 4, 5 and 6
So this is the formula we need! Let's enter it in RUN mode. Recall the paths:
OPTN des (F6) PROB (F3) Ran# (F4)
OPTN des (F6) NUM (F4) Int (F2)
The input should look like figure 7. Press EXE several times and you will see the random numbers from 1 to 6.
Part 5 - Generating a certain range of numbers
Try and work out a formula that will randomly generate numbers 12 to 20.
The answer is figure 8.
Well I think that's enough for one lesson. Well done. We will be revisiting this topic again later on. Please feel free to forward any questions or comments to me by replying to this email or the contact us page at CasioEd (link below).
Have a good Spring holiday! Marty Schmude |