how do calculators choose random nos?

my scientific calculator (casio fx115) has a fuction which chooses any random no. between 0 & 1 ( i think)
what i want to know is how this is achieved (technical answers most welcome)
also i punched in the fuction (ran#-ran#) but the answer was not zero proving that in each instance of a random no. occuring it was different even though it was in the same step.
if anyone can tell me how the random nos are chosen or obtained i’ll be most happy


Generally, all random number generators use algorithms. I’m sure a more mathematically inclined doper can elaborate on that.

…Not being the mathmatically inclined one…

IIRC, calculators and computers use algorithms (think of really, really complex equations) that use a “seed” of some sort, often a running clock, to start the equation…

anymore than that, and someone who actually knows something will have to step in - and I hope they so, because this has puzzled me for some time also.

my wag would be that they use a random number table

Here’s a moderately geeky description of the popular linear congruence algorithm for generating pseudo-random numbers.

Almost certainly your Casio uses something very similar.

To me the most important part of this site is sentence 2:
‘One should not trust these random numbers blindly.’

ur reply helped get me some rest at long last!!

Most random number generators are not really random.

In other words, given the same seed, they will return the same “random” number.

I am sure there are as many algorithms as there are random number generators, but typically it involves doing a number of calculations on the seed number, like dividing it by pi and taking the square root of the result, and then returning the part of the number to the right of the decimal or something similar.

On old programs, you would find that by entering the same seed, you would return the same “random” number. In the days when computer games were things you typed in from a magazine, it wasn’t unusual to get the same cards dealt to you in every game of blackjack, if you started with the same seed.

Now the typical thing is to get the seed from the system clock or something like that so that the results will be different each time the program is run.

It’s also useful sometimes to feed a non-random seed to a random number generator. In games like Microsoft Freecell, for instance, every time you play a game of a certain number, you’ll get the same deal. Rather than making the game remember 32k different permutations of the deck, they just use the game number as the seed for the random number generator that “shuffles” the cards. Same game number, same seed, same card numbers, same deal.

This is a standard thing in simulations as well - you want to be able to use a repeatable random number sequence to validate the tuning of your model before doing a really randomized run for predictive purposes.

You can read more than you probably wanted to know about random number generation in the book Numerical Recipes. Scroll down to chapter 7 for an entire chapter on random numbers :slight_smile:


“random numbers are too important to be left to chance”

why is it I can always remember the quotes but never who said them…

and if you want a more data on random numbers you can look at a book called “applied cryptography” by bruce schneier… it’s a pretty good read… and don’t worry about all the “the book the nsa wanted never to be published” hype, it actually is a good book.

and purely from a mathematical point of view… you can use some second order differential equations to get pseudo random numbers…

Speaking of the NSA…they have a really nifty random number generator that they used to use for their one-time-pads and other keys. They measure the time between clicks on a geiger counter pointed at something which is radioactively decaying.

No mathematical function can give truly random numbers, so in order to get them, you have to turn to silly things like Nature. :slight_smile:

Hey bobo, I suffer from the same affliction, so I know your pain. I either forget the author of the quote, or I mangle the actual quote itself beyond all recognition. Often I wind up doing both. You on the other hand had the quote dead on. It’s attributed to mathematician Robert R. Coveyou at the Oak Ridge National Laboratory. Oher than that I have little to add to the subject of random numbers (this is mainly because math in any form makes me break out in a cold sweat, but really, that’s niether here nor there).

Where does the calculator get the seed? I have a solar-powered calculator - no batteries, so nothing can be stored between uses. Even if the first thing I do is press the random button, I get a different random number each time. Is there some kind of cheap timer chip that uses the time since power-up in microseconds as a seed?

I remember an early, early MIT website where they used a lava lamp to generate random numbers. A camera took a snapshot every few seconds, and calculated how much lava was above/below a certain line, and calculated a number from that.