# Some questions about random numbers

How can I get non-repeating random numbers from Mathematica 8?

How can I know which distribution the numbers I get are?

Can I choose the distribution I want together with the non-repeating random numbers?

How to write the expressions or formulas of permutation and combination?

Are these numbers real random numbers, not pseudo-random numbers?

• Sorry, the "random" numbers in Mathematica are always pseudorandom. If you're fine with that, look into RandomReal[] and RandomVariate[]. Commented May 15, 2012 at 6:31
• Most of your questions (for Mathematica) can be answered if you take a look into the help. 1. Use RandomReal[] or RandomInteger[] or RandomComplex[] without SeedRandom[]. 2. The numbers of RandomReal[] etc. are uniformly distributed over the range you have chosen. 3. Should be possible, take a look at RandomVariate[]. 4. That is something I do not know well, but I think the documentation can help again. 5. They are pseudorandom numbers. Commented May 15, 2012 at 6:35
• For 4: permutations are represented by FactorialPower[]; combinations are represented by Binomial[]. Commented May 15, 2012 at 7:58
• Given the finite number of numbers that can be given with any given fixed amount of precision it is impossible to get an infinite amount non-repeating random numbers. For instance, RandomInteger[9], can only generate 10 different numbers and if we have drawn them all the party is over. So, could you be a bit more explicit about this non-repeating requirement of yours? Commented May 15, 2012 at 9:56
• @SjoerdC.deVries: For a random drawing without repetition with the number of drawings equal the number of available items, I'd expect to get a random permutation of the items. Is there any other possible interpretation? Commented May 15, 2012 at 10:57

You can obtain discrete uniform or normally distributed numbers from random.org, which allows you to generate 200k bits/day.

Import["http://www.random.org/cgi-bin/randbyte?nbytes=1024&format=f", "Binary"]

• That looks like a handy import statement, what format and range do you get ? Commented May 15, 2012 at 9:05
• It looks to be a uniform distribution between 0 and 255. The format is just a list of 1024 integers. Commented May 15, 2012 at 9:27
• @jVincent What result did you get? Executing the Import I got a list of 83 integers between 32 and 121. Executing it again .. I got exactly the same list of 83 numbers, which look suspiciously ASCII in range. Further investigation reveals that the bytes translate to ..."You have used your quota of random bits for today. See the quota page for details." Mystery solved :) Commented May 15, 2012 at 10:05
• Actually, that's a terrible interface for reporting exhausted quota when asking for binary data because it means if you are not careful, your code will silently use non-random values. Instead they should have used an HTTP error (maybe 412 Precondition Failed; if you can extend your quota by paying — I didn't check that — also 402 Payment Required might be reasonable). Commented May 16, 2012 at 7:41
• OK, I now looked at the documentation of the site, and according to their documentation, they indeed do return an error status code (503). That means, the problem is with Mathematica, for ignoring the error. Commented May 16, 2012 at 7:56

If you need high quality non-pseudo random numbers one solution is to use hardware based devices.

One such device can be found here: Quantum Random Number Generator

It's application with Mathematica can be found here: Mathematica QRNG

Available parametric distributions in Mathematica can be found here: MMA Distributions

You can use RandomSample to ensure non-repeating random selection. The example below produces a flat distribution of unique values which you could reduce to the distribution you require. Accuracy is increased by sampling from a larger initial population.

a = RandomSample[Union[RandomInteger[10^7, 10^6]], 10^4];
Histogram[a]
If[Union[a] == Sort[a], "No repeated values", "Repeated values"]