Random Number Generators
Random Number Generators
number generators
Methods used
dice
Flipping a coin
shuffling of playing cards
Slot machines (used in lotteries).etc
Types of RN
a) True RN
some physical phenomenon that is
expected to be random
Eg. Moving a mouse, throwing a dice,
sound parterns
They are unpredictable.
Speudo RN cont
A "random number generator" based
solely on deterministic computation
cannot be regarded as a "true" random
number generator in the purest sense of
the word, since their output is inherently
predictable if all seed values are known
are algorithms that can automatically
create long runs of numbers with good
random properties but eventually the
sequence repeats
Another
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;
int main()
{
srand((unsigned)time(0));
int random_integer;
for(int index=0; index<20; index++)
{
random_integer = (rand()%10)+1;
cout << random_integer << endl;
}
}
Applications of RNG
In applications where numbers
shouldnt be deterministic.eg.airtime
To generate a random report
depending on the random input. This
tries to represent the real world
randomness
Process-oriented simulation
Process: thread of execution describing entity behavior over time
Resources: shared resource used by entities (e.g., runway)
Simulation Primitives