A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

This tag is for questions pertaining to random numbers, whether pseudo random or truly random.

Since different languages may use different RNGs, a question with this tag must also be tagged with the language being used.

All questions pertaining to create random numbers or random distributions: good or bad random number generators (RNGs), how to create specific distributions (gaussian, log-normal) with given parameters from normal random numbers, problems and caveats with given implementations in different languages.

Since different languages may use different RNGs, a question with this tag must also be tagged with the language being used.

Frequently-asked questions

  • How can I generate N uniformly-distributed random real numbers that sum to a given value?
  • How can I choose N elements, avoiding duplicates, from a list (or from the integer range 1..M)?
  • If I create a new random number generator object for each request, why does it return the same value repeatedly? (Or: only seed the random generator once)
  • How do I generate a random integer value within a range?
history | excerpt history