Why are random number generators not random?
A cryptographically secure random number generator is going to take some external source of entropy to make the device non-deterministic. That is why it is impossible to get a truly random number.
What are uniformly distributed numbers?
In statistics, uniform distribution refers to a type of probability distribution in which all outcomes are equally likely. A deck of cards has within it uniform distributions because the likelihood of drawing a heart, a club, a diamond, or a spade is equally likely.
How many times can a random number be generated?
Any number input [i] is generated as many times as its frequency of occurrence because there exists count of integers in range (prefix [i – 1], prefix [i]] is input [i]. Like in the above example 3 is generated thrice, as there exists 3 integers 3, 4 and 5 whose ceil is 5.
Can a random number generator return a probability?
Return a random number with probability proportional to its frequency of occurrence. It is quite clear that the simple random number generator won’t work here as it doesn’t keep track of the frequency of occurrence. We need to somehow transform the problem into a problem whose solution is known to us.
How to create an arbitrary random number generator?
Following is detailed algorithm that uses O (n) extra space where n is number of elements in input arrays. 1. Take an auxiliary array (say prefix []) of size n. 2. Populate it with prefix sum, such that prefix [i] represents sum of numbers from 0 to i.
How to generate a random number from an auxiliary array?
1. Take an auxiliary array (say prefix []) of size n. 2. Populate it with prefix sum, such that prefix [i] represents sum of numbers from 0 to i. 3. Generate a random number (say r) between 1 to Sum (including both), where Sum represents summation of input frequency array.