How does a random number generator work?

shaz

Well-known member
Joined
Jan 9, 2010
Messages
3,183
City & State/Province
Middle Tn
Really,

If it works, how can it truley be random? :???:

What if you had to design one?
 
Put numbers 0-9 on pieces of paper and put them in a hat and draw them out one at a time. If you want a random number greater than 1 digit you would replace the numbered slip of paper each time before drawing the next number.
 
Really,
If it works, how can it truley be random? :???:

Assume you meant a computer random number generator: There is no one RNG used in all systems but programmers/developers either buy one from a software library or build their own. Essentially they all work on the same principle, applying a math function to a number(the Seed) resulting in another number within the range of expect results. There are many ways one can accomplish that task. The very best have equal probability of kicking out every number in the result range.

Getting the seed is where the illusion of randomness is achieved. The seed could be generated from the number of bytes found in the windows temp directory or milliseconds passed since the system was last started. Or the average amount of time between key strokes or just the time of day. Or just about anything which is not easily controlled.

There are a lot of ways to make it appear an RNG is truly random but the exact same set of inputs will always produce the same results. In the end however, an RNG can be "virtually" random if the seed generator is good enough. Imagine a seed number generated based on the number of characters posted on this forum over the past 10 minutes.
 
In another life, in another time when I understood computers and wrote programs I wrote several random number generators. They were an essential part of what I was doing. On one, I used time and a photon collector to collect the "seed" for it to begin its calculations. Basically, at a given start time when the millionth photon hit the collector it began. It was pretty cool but what good it did me I haven't a clue today. But then again, if I remember correctly, I selected the number and the time so that would in a sense could enter into the equation three forms of bias making the results not random. Or maybe not. :???:
 
As an Amazon Associate we earn from qualifying purchases. Product prices and availability are accurate as of the date/time indicated and are subject to change.
Dega Moo":ip7zexjg said:
Really,
If it works, how can it truley be random? :???:

Assume you meant a computer random number generator: There is no one RNG used in all systems but programmers/developers either buy one from a software library or build their own. Essentially they all work on the same principle, applying a math function to a number(the Seed) resulting in another number within the range of expect results. There are many ways one can accomplish that task. The very best have equal probability of kicking out every number in the result range.

Getting the seed is where the illusion of randomness is achieved. The seed could be generated from the number of bytes found in the windows temp directory or milliseconds passed since the system was last started. Or the average amount of time between key strokes or just the time of day. Or just about anything which is not easily controlled.

There are a lot of ways to make it appear an RNG is truly random but the exact same set of inputs will always produce the same results. In the end however, an RNG can be "virtually" random if the seed generator is good enough. Imagine a seed number generated based on the number of characters posted on this forum over the past 10 minutes.


Yeah, that's what I meant. Could be something really junky like a colpits oscillator. If you had a sample of the frequency at some interval it would seem quite random but the range is predictable.
 
Jogeephus":1696k35i said:
In another life, in another time when I understood computers and wrote programs I wrote several random number generators. They were an essential part of what I was doing. On one, I used time and a photon collector to collect the "seed" for it to begin its calculations. Basically, at a given start time when the millionth photon hit the collector it began. It was pretty cool but what good it did me I haven't a clue today. But then again, if I remember correctly, I selected the number and the time so that would in a sense could enter into the equation three forms of bias making the results not random. Or maybe not. :???:


That's the point.
 

Latest posts

Back
Top