Usually when a computer program needs to generate a random number, it treats a known value in the system, or has to contact remote sources that anyway use known data to make more casual numbers.
But the result is still not completly casual, and sometimes predictable.
Now studying latches and flip flops, in a SR latch when S = R = 1 the outcome is unpredictable, so why isn't this used to generate random numbers? Or is it but not generally a diffused method?
Now studying latches and flip flops, in a SR latch when S = R = 1 the outcome is unpredictable, so why isn't this used to generate random numbers?
I believe the flip-flop state is "undefined" rather than random or unpredictable. You might find that a particular flip-flop in a particular circuit is predictable.
An unconnected Arduino digital input is also undefined (it's not reliably high or low) but that doesn't necessarily mean it's high half the time and low half the time. The analog input also "floats" to an unknown/undefined level, but I'm not so sure it doesn't tend to drift toward 0V or 5V and I'd be surprised if the results are truly random.
I try to avoid thinking philosophically about the nature of true randomness, and I take a practical approach. In most applications the results can be "random enough". If you can't predict the outcome, it's random enough.
I'm pretty sure casino slot machines don't use any true random number methods. I assume they use a pseudorandom algorithm that's more advanced than the basic C++ random() function.
With the Arudino, using analogRead() to seed the random sequence is often good enough. It's better if you have an application that's actually reading an unknown analog signal. If there's a power supply, you may be able to tap-into the AC to get a varying analog voltage that's uncorrelated to the processor's clock to get a random-like seed. (Anything that's uncorrelated with the processor will be less predictable.)
Another approach is to run a loop that's generating random (pseudorandom) numbers in the background, then "grab" one of those random numbers when the user pressed a button (at a random time). With the processor running at MHz rates, the timing of a human key-press is virtually random.
Mh, everywhere, in the internet, in my schoolbook, the very word that's used is unpredictable.....
It's not that I'm going to build a random number generator, I was just wondering;
Anyway, all your methods are better that the one I found on an old account on a pc in school lab:
int RandomNumber()
{
return 4; // chosen by fair dice roll.
// guaranteed to be random.
}
I'm pretty sure casino slot machines don't use any true random number methods. I assume they use a pseudorandom algorithm that's more advanced than the basic C++ random() function.
I don't know, they should but they also define the rules of the game.
If the nr. of winning combinations is less than the nr. of failing combinations, they still win.
Mh, everywhere, in the internet, in my schoolbook, the very word that's used is unpredictable.....
It's not that I'm going to build a random number generator, I was just wondering;
The R = S = 1 combination is called a restricted combination or a forbidden state because, as both NOR gates then output zeros, it breaks the logical equation Q = not Q. The combination is also inappropriate in circuits where both inputs may go low simultaneously (i.e. a transition from restricted to keep). The output would lock at either 1 or 0 depending on the propagation time relations between the gates (a race condition).
I don't know, they should but they also define the rules of the game.
From what I've read, true random number generators use radioactivity. That's something you might use in a physics lab, but it's not something you normally use in everyday manufacturing.
You can download true random numbers from [u]random.org[/u] that are generated from atmospheric noise (atmospheric radiation).
When both inputs are high at once, however, there is a problem: it is being told to simultaneously produce a high Q and a low Q. This produces a "race condition" within the circuit - whichever flip flop succeeds in changing first will feedback to the other and assert itself. Ideally, both gates are identical and this is "metastable", and the device will be in an undefined state for an indefinite period. In real life, due to manufacturing methods, one gate will always win, but it's impossible to tell which it will be for a particular device
from an assembly line. The state of S = R = 1 is therefore "illegal" and should never be entered.
wikibooks.
Does that mean that there is a way to predict the "unpredictable" state for a specific device, but it is different from one to another?
Read up on the generation of truly random numbers. It turns out to be quite difficult, because many so-called "unpredictable" events that might be used as generator seeds turn out to have serious issues with bias.
For example, the flip flop output could unpredictable, but much more often in the 1 state than the 0 state.
The time between radioactive decay events is a popular seed for random number generators.
If you do a search on my name and the word random,
you should come across a white noise generator.
It can be used with a counter to supply random numbers.
I just posted it earlier today.
Many random functions are know to alternate between odd
and even ( not so random ).
These are all not true random number generators. Still some
won't repeat during the time of the universe.
If used for a small number, I always recommend using middle
digits and not ends.
Dwight
ondsinet:
Now studying latches and flip flops, in a SR latch when S = R = 1 the outcome is unpredictable, so why isn't this used to generate random numbers? Or is it but not generally a diffused method?
The state can be entirely predictable for S=R=1.
The only random behaviour is when S and R both transition simultaneously to 1. And for a particular
flip-flop it may be completely predicatable, or somewhat random, or fairly random, and may be temperature
and age dependent.
This is a race-condition and not a source of quality randomness at all. Quantum or chaotic processes
are needed for good randomness, and even then you have to great care to avoid correlation between
samples and to avoid bias or even detect when the system isn't being truly random because its broken
(and is only being vaguely random).
While it is unpredictable for any one given hardware it is always consistent. So you wire a circuit and it always gives a one. There is no way to predict this in advance of building it but once built it will always give the same result.
You could say it is predictable because you always know what it is going to be, but that is not what predictable means. It means that every time you make that circuit you will always have the same result. This is not the case, but it is useless for generating random numbers.