<p>With probability, it is usually easier to find the negative case and subtract from <code>1</code>.</p>

<p>So what are the chances of dice rolls being unique?</p>

<pre><code>One roll unique:
1

One roll at least one clash:
1 - 1 = 0

Two rolls unique:
1 * 5/6 (only 5 numbers left)

Two rolls at least one clash:
1 - 1 * 5/6

Three rolls unique:
1 * 5/6 * 4/6

Three rolls at least one clash:
1 - 1 * 5/6 * 4/6
</code></pre>

<p>So for 32 bit nonces:</p>

<pre><code>1 - 1
1 - 1 * (2^32 - 1)/2^32
1 - 1 * (2^32 - 1)/2^32 * (2^32 - 2)/2^32
</code></pre>

<p>So for 500K in 2^32 I wrote this:</p>

<pre><code>var uniqueChance = 1.toDouble()
val max: Double = 4_294_967_296.toDouble()
for (i in 1..500000) {
    uniqueChance *= (max - i) / max
}
println("Chance of unique $uniqueChance")
println("Chance of at least one duplicate ${1 - uniqueChance}")
</code></pre>

<p>Which gives:</p>

<pre><code>Chance of unique 2.2900830840065387E-13
Chance of at least one duplicate 0.999999999999771
</code></pre>

CC BY-SA 3.0
2018-04-14T13:42:00.697Z
2018-04-14T13:47:48.103Z
2018-04-14T13:47:48.103Z
weston
<p>Assuming that nonces are randomly distributed (which they should be) and after 1 million blocks that no blocks have the same nonce, the probability of the <strong>next block having the same nonce as a block that has already been mined</strong> is 1000000/4294967296 = 0.000233, so very low. However as more blocks are being mined, the probability increases. Once there are 4294967296 blocks, the probability of a block sharing a nonce with a different block is guaranteed.</p>

<p>The reasoning for 4294967296 is because the nonce is a 32-bit integer so there are 2^32 possible nonces which is 4294967296.</p>

<p>However, the probability of <strong>any 2 blocks having the same nonce</strong> is 1/65536 due to the birthday paradox.</p>

<p>There currently have been multiple pairs of blocks that have the same nonce. Some are listed below:</p>

<pre><code>Nnoce: 68229731, blocks [9459, 35238]
Nnoce: 3147243286, blocks [19411, 71181]
Nnoce: 2811235843, blocks [42202, 110904]
Nnoce: 61366272, blocks [100255, 171713]
Nnoce: 74571595, blocks [37187, 176000]
Nnoce: 22876413, blocks [22460, 188416]
Nnoce: 131829089, blocks [40784, 203153]
Nnoce: 2962306894, blocks [136018, 216500]
Nnoce: 3947837747, blocks [222990, 227103]
Nnoce: 194800186, blocks [36506, 243089]
Nnoce: 1388988687, blocks [108366, 251694]
Nnoce: 922984712, blocks [245295, 260005]
Nnoce: 4133916719, blocks [176525, 276110]
Nnoce: 3890141599, blocks [213608, 292419]
Nnoce: 876374308, blocks [18857, 317190]
Nnoce: 70651752, blocks [238831, 322634]
Nnoce: 2359983768, blocks [112651, 325309]
Nnoce: 3421780225, blocks [95525, 328515]
Nnoce: 3787474772, blocks [187117, 346581]
Nnoce: 3956410682, blocks [10506, 350632]
Nnoce: 2756846708, blocks [117891, 355889]
Nnoce: 158953652, blocks [305592, 368094]
Nnoce: 2660238194, blocks [257198, 371219]
Nnoce: 2774929041, blocks [112737, 413142]
Nnoce: 2335903164, blocks [379609, 436786]
Nnoce: 64632759, blocks [60105, 443347]
Nnoce: 2469851573, blocks [225526, 448132]
Nnoce: 84018796, blocks [78009, 453373]
Nnoce: 1935967937, blocks [436055, 454540]
Nnoce: 2900822784, blocks [144802, 457849]
Nnoce: 2434589573, blocks [102268, 467087]
Nnoce: 2965485942, blocks [366411, 481531]
Nnoce: 18390814, blocks [68360, 506618]
Nnoce: 433452460, blocks [157144, 513320]
</code></pre>

CC BY-SA 3.0
2018-04-14T03:17:41.430Z
Actually, because of the [birthday paradox](https://en.wikipedia.org/wiki/Birthday_problem), it is overwhelmingly likely that there have been two blocks with the same nonce.  With the 500000 blocks so far, if I'm calculating right, the probability is at least 0.999999999999.  I'll check the actual values and post an answer.
Nate Eldredge
CC BY-SA 3.0
2018-04-14T03:22:38.217Z
Ah, right. The probability of any 2 blocks having the same nonce is 1/2^16 due to the birthday paradox.
Ava Chow
CC BY-SA 3.0
2018-04-14T03:28:57.970Z
The probability that any **given** pair of blocks have the same nonce is 1/2^32.  But there have been roughly 500000^2 pairs of blocks, which is much greater than 2^32.  So the expected number of matching pairs so far is 500000^2/2^32 = 58.
Nate Eldredge
CC BY-SA 3.0
2018-04-16T15:25:50.613Z
@AndrewChow Ah i see, you initially were calculating the chance of a nonce being shared with any other nonce, not any nonce having a pair with another nonce. The birthday paradox works nicely here, could it be used to predict future nonces?
DjangoBlockchain
CC BY-SA 3.0
2018-04-16T15:31:29.247Z
No, the birthday paradox cannot be used to predict which values will collide.
Ava Chow
CC BY-SA 3.0
2018-04-14T01:35:15.510Z
2018-04-14T03:26:31.043Z
2018-04-14T03:26:31.043Z
Ava Chow
<p>Just to put a cap, let’s say in 1 million blocks, what is the chance that 2 blocks will share the same nonce value? Has it happened before? </p>

<blockchain>
What are the chances that a nonce for one block is a nonce for another?
DjangoBlockchain
# What are the chances that a nonce for one block is a nonce for another?

(Asked by: username_0 on 2018-04-14)

Just to put a cap, let’s say in 1 million blocks, what is the chance that 2 blocks will share the same nonce value? Has it happened before?

**Tags:** blockchain


---

## 2 answers

### Answer by username_2 on 2018-04-14. Score: 8 | Accepted answer

Assuming that nonces are randomly distributed (which they should be) and after 1 million blocks that no blocks have the same nonce, the probability of the **next block having the same nonce as a block that has already been mined** is 1000000/4294967296 = 0.000233, so very low. However as more blocks are being mined, the probability increases. Once there are 4294967296 blocks, the probability of a block sharing a nonce with a different block is guaranteed.

The reasoning for 4294967296 is because the nonce is a 32-bit integer so there are 2^32 possible nonces which is 4294967296.

However, the probability of **any 2 blocks having the same nonce** is 1/65536 due to the birthday paradox.

There currently have been multiple pairs of blocks that have the same nonce. Some are listed below:

```
Nnoce: 68229731, blocks [9459, 35238]
Nnoce: 3147243286, blocks [19411, 71181]
Nnoce: 2811235843, blocks [42202, 110904]
Nnoce: 61366272, blocks [100255, 171713]
Nnoce: 74571595, blocks [37187, 176000]
Nnoce: 22876413, blocks [22460, 188416]
Nnoce: 131829089, blocks [40784, 203153]
Nnoce: 2962306894, blocks [136018, 216500]
Nnoce: 3947837747, blocks [222990, 227103]
Nnoce: 194800186, blocks [36506, 243089]
Nnoce: 1388988687, blocks [108366, 251694]
Nnoce: 922984712, blocks [245295, 260005]
Nnoce: 4133916719, blocks [176525, 276110]
Nnoce: 3890141599, blocks [213608, 292419]
Nnoce: 876374308, blocks [18857, 317190]
Nnoce: 70651752, blocks [238831, 322634]
Nnoce: 2359983768, blocks [112651, 325309]
Nnoce: 3421780225, blocks [95525, 328515]
Nnoce: 3787474772, blocks [187117, 346581]
Nnoce: 3956410682, blocks [10506, 350632]
Nnoce: 2756846708, blocks [117891, 355889]
Nnoce: 158953652, blocks [305592, 368094]
Nnoce: 2660238194, blocks [257198, 371219]
Nnoce: 2774929041, blocks [112737, 413142]
Nnoce: 2335903164, blocks [379609, 436786]
Nnoce: 64632759, blocks [60105, 443347]
Nnoce: 2469851573, blocks [225526, 448132]
Nnoce: 84018796, blocks [78009, 453373]
Nnoce: 1935967937, blocks [436055, 454540]
Nnoce: 2900822784, blocks [144802, 457849]
Nnoce: 2434589573, blocks [102268, 467087]
Nnoce: 2965485942, blocks [366411, 481531]
Nnoce: 18390814, blocks [68360, 506618]
Nnoce: 433452460, blocks [157144, 513320]

```

> **Comments:**
> **username_3**: Actually, because of the [birthday paradox](https://en.wikipedia.org/wiki/Birthday_problem), it is overwhelmingly likely that there have been two blocks with the same nonce.  With the 500000 blocks so far, if I'm calculating right, the probability is at least 0.999999999999.  I'll check the actual values and post an answer.  
> **username_2**: Ah, right. The probability of any 2 blocks having the same nonce is 1/2^16 due to the birthday paradox.  
> **username_3**: The probability that any **given** pair of blocks have the same nonce is 1/2^32.  But there have been roughly 500000^2 pairs of blocks, which is much greater than 2^32.  So the expected number of matching pairs so far is 500000^2/2^32 = 58.  
> **username_0**: @AndrewChow Ah i see, you initially were calculating the chance of a nonce being shared with any other nonce, not any nonce having a pair with another nonce. The birthday paradox works nicely here, could it be used to predict future nonces?  
> **username_2**: No, the birthday paradox cannot be used to predict which values will collide.  

---

### Answer by username_1 on 2018-04-14. Score: 2

With probability, it is usually easier to find the negative case and subtract from `1`.

So what are the chances of dice rolls being unique?

```
One roll unique:
1

One roll at least one clash:
1 - 1 = 0

Two rolls unique:
1 * 5/6 (only 5 numbers left)

Two rolls at least one clash:
1 - 1 * 5/6

Three rolls unique:
1 * 5/6 * 4/6

Three rolls at least one clash:
1 - 1 * 5/6 * 4/6

```

So for 32 bit nonces:

```
1 - 1
1 - 1 * (2^32 - 1)/2^32
1 - 1 * (2^32 - 1)/2^32 * (2^32 - 2)/2^32

```

So for 500K in 2^32 I wrote this:

```
var uniqueChance = 1.toDouble()
val max: Double = 4_294_967_296.toDouble()
for (i in 1..500000) {
    uniqueChance *= (max - i) / max
}
println("Chance of unique $uniqueChance")
println("Chance of at least one duplicate ${1 - uniqueChance}")

```

Which gives:

```
Chance of unique 2.2900830840065387E-13
Chance of at least one duplicate 0.999999999999771

```


---

