# True Randomness

**URL:** <https://boards.straightdope.com/t/true-randomness/1016155>\
**Category:** Factual Questions\
**Created:** [March 26, 2025, 8:10pm UTC](https://boards.straightdope.com/t/true-randomness/1016155 "2025-03-26T20:10:45Z")\
**Posts on this page:** 20\
**Page:** 4

<div class="post-metadata">

**Author:** ![DPRK](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@DPRK](https://boards.straightdope.com/u/DPRK)\
**Post date:** [April 8, 2025, 2:34pm UTC](https://boards.straightdope.com/t/true-randomness/1016155/61 "2025-04-08T14:34:25Z")

</div>

Imagine just rolling a 10-sided die to generate digits, though, if you want a random number between 0 and 1. Why go through a Gaussian distribution if you do not need to?

---

<div class="post-metadata">

**Author:** ![Pleonast](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pleonast/32/1183_2.png) [@Pleonast](https://boards.straightdope.com/u/Pleonast)\
**Post date:** [April 8, 2025, 2:43pm UTC](https://boards.straightdope.com/t/true-randomness/1016155/62 "2025-04-08T14:43:11Z")

</div>

It all depends on the details.

What are we using the random number for?  
How quickly do we need random numbers?  
How well do we know the actual distribution of the physical source of randomness?

It’s more engineering than mathematics.

---

<div class="post-metadata">

**Author:** ![LSLGuy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lslguy/32/5813_2.png) [@LSLGuy](https://boards.straightdope.com/u/LSLGuy)\
**Post date:** [April 8, 2025, 2:43pm UTC](https://boards.straightdope.com/t/true-randomness/1016155/63 "2025-04-08T14:43:59Z")

</div>

> [@Great\_Antibob](#):
>
> > [@LSLGuy](#):
> >
> > That gives a very crude and lumpy approximation of a Gaussian distribution. Call it a “badly pixelated Gaussian” and you have the flavor even if that’s mathematically not strictly true.
> 
> Central Limit Theorem being what it is, it actually is sort of true. And becomes more true as you add more dice.

Thank you for solidifying that.

As I was typing that up I could not recall if that 2-dice roll distribution was properly strictly Gaussian or was simply an example of something symmetrical with a peak in the middle. IIRC all Gaussians are symmetrical with a single peak in the center, but the converse is not true. Gaussians are a proper subset of single-peaked symmetrical.

And I was too lazy to look it up. Hence my weasel words.

---

<div class="post-metadata">

**Author:** ![Pasta](https://avatars.discourse-cdn.com/v4/letter/p/ecccb3/32.png) [@Pasta](https://boards.straightdope.com/u/Pasta)\
**Post date:** [April 8, 2025, 4:57pm UTC](https://boards.straightdope.com/t/true-randomness/1016155/64 "2025-04-08T16:57:19Z")

</div>

> [@DPRK](#):
>
> For example, going from a Gaussian distribution to a uniform distribution can be accomplished via an inverse Box–Muller transform or many other alternatives.

Does anybody do that? The Box-Muller transform is used widely in the other (non-inverse) direction to turn a source of uniformly distributed random values into a source of Gaussian distribution random values.

(And to define it for folks: if you have two independent random numbers u\_1 and u\_2 distributed uniformly between 0 and 1, then the variables x\_1 = \sqrt{-2\log u\_1}\cos(2\pi u\_2) and x\_2 = \sqrt{-2\log u\_2}\sin(2\pi u\_1) are independent random numbers distributed as a standard normal, _i.e._ as a Gaussian with mean 0 and standard deviation 1.)

> [@CookingWithGas](#):
>
> what application would you want truly random data for, yet also want it to be uniformly distributed?

To distill the point here: “uniformly distributed” isn’t a requirement on the output; it’s a requirement on the probability of the output. Drawing ten random digits uniformly distributed from 0 to 9, is very very unlikely to get you a “uniform” set of all ten possible digits. But each digit had the the same (hence: uniform) probability of being drawn each time.

> [@LSLGuy](#):
>
> That gives a very crude and lumpy approximation of a Gaussian distribution.

The Gaussian limit is of interest to be sure, but for the case of two dice rolls or other uniform distribution, the distribution of their sum is perfectly triangular. For two dice:

```auto
P(2) = 1/36
P(3) = 2/36
P(4) = 3/36
P(5) = 4/36
P(6) = 5/36
P(7) = 6/36
P(8) = 5/36
P(9) = 4/36
P(10) = 3/36
P(11) = 2/36
P(12) = 1/36

```

---

<div class="post-metadata">

**Author:** ![RitterSport](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/rittersport/32/6326_2.png) [@RitterSport](https://boards.straightdope.com/u/RitterSport)\
**Post date:** [April 8, 2025, 5:26pm UTC](https://boards.straightdope.com/t/true-randomness/1016155/65 "2025-04-08T17:26:55Z")

</div>

What’s the formula for 6 dice?

---

<div class="post-metadata">

**Author:** ![Great\_Antibob](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@Great\_Antibob](https://boards.straightdope.com/u/Great_Antibob)\
**Post date:** [April 8, 2025, 5:48pm UTC](https://boards.straightdope.com/t/true-randomness/1016155/66 "2025-04-08T17:48:20Z")

</div>

As it happens, you can use Pascal’s triangle.

P(6) = 1/46656 1 = 1st entry on 6th row  
P(7) = 6/46656 6 = 2nd entry on 7th row  
P(8) = 21/46656 21 = 3rd entry on 8th row  
P(9) = 56/46656 56 = 4th entry on 9th row  
P(10) = 126/46656 126 = 5th entry on 10th row  
P(11) = 252/46656 252 = 6th entry on 11th row  
and so on

With that many dice, you get a reasonably good bell curve made of piecewise 5th order polynomial bits.

This works with any number of dice. Just start on the row corresponding to the number of dice.

ETA: you do need to stop at the halfway point, though, i.e. for 2 dice, stop at P(7) and for 6 dice, stop at P(21). The probabilities are naturally symmetric about that point.

---

<div class="post-metadata">

**Author:** ![RitterSport](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/rittersport/32/6326_2.png) [@RitterSport](https://boards.straightdope.com/u/RitterSport)\
**Post date:** [April 8, 2025, 5:56pm UTC](https://boards.straightdope.com/t/true-randomness/1016155/67 "2025-04-08T17:56:27Z")

</div>

That’s a pretty big “and so on”. Where does 46656 come from? I’m sorry I’m so dense today.

So, for P(7), I go to the 7th row of Pascal’s triangle and take the second entry?

There must be some general formula, or at least some specific formula for n dice, right?

---

<div class="post-metadata">

**Author:** ![Great\_Antibob](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@Great\_Antibob](https://boards.straightdope.com/u/Great_Antibob)\
**Post date:** [April 8, 2025, 6:04pm UTC](https://boards.straightdope.com/t/true-randomness/1016155/68 "2025-04-08T18:04:24Z")

</div>

46656 = 6^6, since you have 6 dice.

For 2 dice, it’s 36 since 6^2 = 36. For 3 dice, it would be 216 since 6^3 = 216.

For 6 dice, yes, P(7) is the 2nd entry on the 7th row

You can just look at the corresponding diagonal on the triangle. It’s a straight line down.

But for completeness, here’s the rest of the list:

P(12) = 462 / 46656  
P(13) = 792 / 46656  
P(14) = 1287 / 46656  
P(15) = 2002 / 46656  
P(16) = 3003 / 46656  
P(17) = 4368 / 46656  
P(18) = 6188 / 46656  
P(19) = 8568 / 46656  
P(20) = 11628 / 46656  
P(21) = 15504 / 46656

From there, P(22) = P(20), P(23) = P(19), and so on.

As for a general method, sure, though the formula is a bit complex for the general case. You can find a derivation on this page.

> **[Deriving the probability distribution for the sum of many dice rolls](https://www.analyticscheck.net/posts/sums-dice-rolls/)**
>
> Rolling one or two dice is simple. Rolling a whole handful is not. In this post, we derive the probability distribution that describes the sum of many dice.

Note that it is equivalent to finding coefficients of a polynomial, which is the link back to Pascal’s triangle.

---

<div class="post-metadata">

**Author:** ![Great\_Antibob](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@Great\_Antibob](https://boards.straightdope.com/u/Great_Antibob)\
**Post date:** [April 8, 2025, 6:21pm UTC](https://boards.straightdope.com/t/true-randomness/1016155/69 "2025-04-08T18:21:05Z")

</div>

Oh wait, I made a mistake somewhere. Website is good for the formula but the numbers are off.

---

<div class="post-metadata">

**Author:** ![RitterSport](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/rittersport/32/6326_2.png) [@RitterSport](https://boards.straightdope.com/u/RitterSport)\
**Post date:** [April 8, 2025, 6:22pm UTC](https://boards.straightdope.com/t/true-randomness/1016155/70 "2025-04-08T18:22:31Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![Great\_Antibob](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@Great\_Antibob](https://boards.straightdope.com/u/Great_Antibob)\
**Post date:** [April 8, 2025, 6:56pm UTC](https://boards.straightdope.com/t/true-randomness/1016155/71 "2025-04-08T18:56:35Z")

</div>

Welp, never mind that bit about the triangle. That works up to sum P(11). Much more complicated for the higher numbers where you have to subtract off a bit.

Mea culpa

The real figures using the formula:

P(6) = 1/46656  
P(7) = 6/46656  
P(8) = 21/46656  
P(9) = 56/46656  
P(10) = 126/46656  
P(11) = 252/46656  
P(12) = 456 / 46656  
P(13) = 756 / 46656  
P(14) = 1161 / 46656  
P(15) = 1666 / 46656  
P(16) = 2247 / 46656  
P(17) = 2856 / 46656  
P(18) = 3431 / 46656  
P(19) = 3906 / 46656  
P(20) = 4221 / 46656  
P(21) = 4332 / 46656

And again, the numbers bigger than 21 you get from symmetry. Double checked this time, and they all add up to 46656, so that’s good

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [April 8, 2025, 8:45pm UTC](https://boards.straightdope.com/t/true-randomness/1016155/72 "2025-04-08T20:45:38Z")

</div>

> [@Great\_Antibob](#):
>
> Central Limit Theorem being what it is, it actually is sort of true. And becomes more true as you add more dice.

Of course, you almost never actually have a true Gaussian, and you’ll certainly never get one by adding together dice, because n d m always has a minimum possible value and a maximum possible value, while the tails of a true Gaussian extend infinitely. And there are also many real-world distributions that fail to be Gaussian by having fatter tails than a true Gaussian.

What makes Gaussians so useful is not that they’re common, but that they’re a good approximation for many real-world distributions, especially when you’re not too far from the center of the distribution.

> [@DPRK](#):
>
> Imagine just rolling a 10-sided die to generate digits, though, if you want a random number between 0 and 1. Why go through a Gaussian distribution if you do not need to?

I think one reason might be if you don’t fully trust your dice. If I want 10 decimal digits, I could roll a 10-sided die ten times, but if my d10 is biased, then my results will be, too. But even if my die is biased, if I roll it 10 times and add the results together, I’m going to get something that’s extremely close to a Gaussian distribution (even if it’s not the same Gaussian distribution I expected).

---

<div class="post-metadata">

**Author:** ![RitterSport](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/rittersport/32/6326_2.png) [@RitterSport](https://boards.straightdope.com/u/RitterSport)\
**Post date:** [April 8, 2025, 9:08pm UTC](https://boards.straightdope.com/t/true-randomness/1016155/73 "2025-04-08T21:08:08Z")

</div>

Thanks! That makes my graph look a lot more like I expected it to.

---

<div class="post-metadata">

**Author:** ![Pasta](https://avatars.discourse-cdn.com/v4/letter/p/ecccb3/32.png) [@Pasta](https://boards.straightdope.com/u/Pasta)\
**Post date:** [April 8, 2025, 11:41pm UTC](https://boards.straightdope.com/t/true-randomness/1016155/74 "2025-04-08T23:41:16Z")

</div>

> [@Chronos](#):
>
> I think one reason might be if you don’t fully trust your dice. If I want 10 decimal digits, I could roll a 10-sided die ten times, but if my d10 is biased, then my results will be, too. But even if my die is biased, if I roll it 10 times and add the results together, I’m going to get something that’s extremely close to a Gaussian distribution (even if it’s not the same Gaussian distribution I expected).

This will never be a practical application for unbiasing a die. Even after the upfront costs for normalizing the Gaussian, you would need massive number of rolls per draw to wash out the discretization. No one would do this. Worst case, you would just generate a boring unbiased bitstring from the biased die outputs instead.\*

\*This could simply be via the “coin flip” unbiasing from upthread: Let rolls 0-4 be called output A and rolls 5-9 be called output B. Roll twice to get a pair of outputs. AB = bit 0. BA = bit 1. AA = BB = discard the outputs and try again. This will generate an unbiased string of 0s and 1s to use for whatever, including implementing an unbiased d10 despite the original entropy source being a biased d10. For maximum efficiency (optional), group the rolls into output buckets A and B in as close to a 50%/50% way as possible with the biased die.

---

<div class="post-metadata">

**Author:** ![DPRK](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@DPRK](https://boards.straightdope.com/u/DPRK)\
**Post date:** [April 9, 2025, 2:20am UTC](https://boards.straightdope.com/t/true-randomness/1016155/75 "2025-04-09T02:20:18Z")

</div>

> [@Pasta](#):
>
> > [@DPRK](#):
> >
> > For example, going from a Gaussian distribution to a uniform distribution can be accomplished via an inverse Box–Muller transform or many other alternatives.
> 
> Does anybody do that?

I am not suggesting anyone would or should; it was meant as an example. If your x\_1 and x\_2 are independent standard normals then the inverse of the Box–Muller transform (which _is_ actually usefully used in the non-inverse direction) will be something like u\_1=e^{-(x\_1^2+x\_2^2)/2}, u\_2=\frac{1}{2 \pi}\arctan(x\_1/x\_2)

---

<div class="post-metadata">

**Author:** ![Saffer](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/saffer/32/6440_2.png) [@Saffer](https://boards.straightdope.com/u/Saffer)\
**Post date:** [April 11, 2025, 10:56am UTC](https://boards.straightdope.com/t/true-randomness/1016155/76 "2025-04-11T10:56:30Z")

</div>

And, for the sake of completeness, the box muller transform is computationally efficient, but only works for moving between Gaussian and uniform distributions.

But, for any arbitrary distribution, you can move between that distribution and a uniform distribution by applying the cumulative distribution function, or its inverse. But although this would work for any distribution, it might not be the fastest way to do it on a large scale.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [April 11, 2025, 12:34pm UTC](https://boards.straightdope.com/t/true-randomness/1016155/77 "2025-04-11T12:34:21Z")

</div>

Again, if, of course, you know what the distribution actually is.

---

<div class="post-metadata">

**Author:** ![DPRK](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@DPRK](https://boards.straightdope.com/u/DPRK)\
**Post date:** [April 13, 2025, 1:33pm UTC](https://boards.straightdope.com/t/true-randomness/1016155/78 "2025-04-13T13:33:58Z")

</div>

If you look at computer algorithms like this [https://www.schneier.com/wp-content/uploads/2015/12/fortuna.pdf](https://www.schneier.com/wp-content/uploads/2015/12/fortuna.pdf)  
what they do is ingest some unpredictable data from different sources, which you may not know everything about, and use that to _seed_ a pseudo-random number generator in such a way that the output remains unpredictable.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [April 13, 2025, 5:03pm UTC](https://boards.straightdope.com/t/true-randomness/1016155/79 "2025-04-13T17:03:55Z")

</div>

For many purposes, it’s good enough to just take a completely predictable (but constantly changing) input, like the current system time, and use that to seed the PRNG.

---

<div class="post-metadata">

**Author:** ![markn\_1](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@markn\_1](https://boards.straightdope.com/u/markn_1)\
**Post date:** [April 13, 2025, 5:07pm UTC](https://boards.straightdope.com/t/true-randomness/1016155/80 "2025-04-13T17:07:39Z")

</div>

Perhaps for simulations or something like that, but such an algorithm would be completely unacceptable for cryptographic purposes. An adversary could easily guess the seed in a small number of attempts, and then predict the sequence of “random” numbers.

[Previous page](https://boards.straightdope.com/t/true-randomness/1016155.md?page=3)

[Next page](https://boards.straightdope.com/t/true-randomness/1016155.md?page=5)
