1
$\begingroup$

Most functions that generate random numbers are described as:

Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive)

If I use it to generate a number in the range [0..9], does uniformly distributed mean that the probability for 3 and 8 is the same?

As I understand it, if I run the function a sufficient number of times, I'll have the same number of occurrences for each number, 0 through 9. Is this correct?

Alternatively, would we instead have a normal distribution where we would get more occurrences of the numbers 4, 5, and 6, as they are closer to the mean and hence have a higher probability of occurring?

$\endgroup$
3
$\begingroup$

Uniform distribution is when all values have the same probability. A random uniformly distributed integer in the range $0,\ldots,9$ will attain each of the values with probability $1/10$. In practice, you function is not truly random but only pseudorandom, so the probabilities won't be exactly $1/10$ but only very close to $1/10$.

Normal distribution is a probability distribution on real numbers. If we "bin" them then we get a normal distribution on the integers. If we "cap" it (there are several ways of doing this) then we get a probability distribution on a finite set of integers.

$\endgroup$
  • $\begingroup$ thanks, so all my assertions in the question body are correct, right? Normal distribution is a probability distribution on real numbers. - can you please clarify? $\endgroup$ – Maxim Koretskyi May 17 '17 at 15:45
  • 1
    $\begingroup$ The normal distribution is a probability distribution (in fact, a family of probability distributions) on the real numbers. Sometimes people say "normal distribution" when they actually mean some discretization of the normal distribution. $\endgroup$ – Yuval Filmus May 17 '17 at 15:56
  • $\begingroup$ _ If we "bin" them then we get a normal distribution on the integers. If we "cap" it_ - thanks, where can I read about bin and cap you're talking about? $\endgroup$ – Maxim Koretskyi May 18 '17 at 16:06
  • $\begingroup$ Some question on this site mentioned discretized normal distribution, but I don't of any other particular source, though I imagine it's common in some circles. $\endgroup$ – Yuval Filmus May 18 '17 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.