<p>Great question.</p>
<p>So the general gist of 'random walk' is contingent on two different things:</p>
<ol>
<li><p>Probability</p>
</li>
<li><p>Logic</p>
</li>
</ol>
<p>It's better to start with the logic part because it will make the probability portion more logical.</p>
<h3>Looking at the Logic</h3>
<p>From the Bitcoin whitepaper, Satoshi states:</p>
<blockquote>
<p>&quot;The race between the honest chain and an attacker chain can be characterized as a Binomial Random Walk. The success event is the honest chain being extended by one block, increasing its lead by +1, and the failiure event is the attacker's chain being extended by one block, reducing the gap by -1.&quot;</p>
</blockquote>
<blockquote>
<p>&quot;The probability of an attacker catching up from a given deficit is analogous to a Gambler's Ruin problem. Suppose a gambler with unlimited credit starts at a deficit and plays potentially an infinite number of trials to try to reach breakeven.&quot;</p>
</blockquote>
<h3>Breaking This Down</h3>
<p>If we were to consider a miner to be an &quot;attacker&quot; then that means that they must have &quot;reversed&quot; a transaction they spent in order to spend it elsewhere (maybe to a wallet they own).</p>
<p>Using this principle, we know that the transaction <strong>must be in the past</strong>.</p>
<p>So if we're mining at block height 'n', then <strong>at best</strong>, the attacker must start at n-1 (since they need to reverse a transaction that already was mined in a block).</p>
<h3>Here's Where Probability Comes in</h3>
<p>As that miner attempts to catch up to the network, they're already at an inherent disadvantage since they're a block behind.</p>
<p>Assuming the network solves for 'n' before the attacker solves 'n-1', then their chances of then solving 'n-1', 'n', then ultimately solving 'n+1' (the new block that the network is working on) decreases substantially.</p>
<p>With this decreased possibility of catching up, the network's probability of extending the lead then increases.</p>
<p><strong>Formula</strong></p>
<p>Not sure if this suffices, but Satoshi included both a formula and C code in the original whitepaper.</p>
<p>The formula is as follows:</p>
<p><a href="https://i.sstatic.net/mtMfn.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/mtMfn.png" alt="from the bitcoin whitepaper" /></a></p>
<p><a href="https://i.sstatic.net/SIqD6.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/SIqD6.png" alt="bitcoin whitepaper excerpt part two" /></a></p>
<p>The C code is as follows:</p>
<pre><code>
#include &quot;math.h&quot;
#include &quot;stdio.h&quot;

double AttackerSuccessProbability(double q, int z)
{
 double p = 1.0 - q;
 double lambda = z * (q / p);
 double sum = 1.0;
 int i; 
 int k;
 for (k = 0; k &lt;= z; k++)
 {
     double poisson = exp(-lambda);
     
     for (i = 1; i &lt;= k; i++)
     poisson *= lambda / i;
     sum -= poisson * (1 - pow(q / p, z - k));
 }
 return sum;
}

int main()
{
double ans = AttackerSuccessProbability(0.1, 1);
printf(&quot;'%f'&quot;, ans);
}
</code></pre>
<p>Hopefully this explanation thus far makes sense (and you find the answer to your question to be adequate)</p>

CC BY-SA 4.0
2020-12-18T06:55:55.690Z
2020-12-18T06:55:55.690Z
librehash
<p>I am not familiar with Bitcoin, hope someone can tell me why. Thank you!</p>
<p>Let's consider the following scenario.</p>
<p>The probability of the attacker finds the next block is q and the probability of the honest node finds the next block is p.</p>
<p>Suppose the attacker and the honest node began to find the next block in the meantime (so they spend the same time on finding the PoW solution). If now the attacker finds the next block, since the attacker will not broadcast the block, it won't affect the honest node. The honest node will continue to work on its own PoW. So maybe the probability of the honest node finds the next block is larger than p now (Because the honest node now will spend more time than the attacker on finding the solution of the next block's PoW).
Why can Satoshi consider this catch-up process as the gambler game? Is this just a simplified math model? Or is there any procedure I don't know such that once one node finds the next block, all miners will restart their mining work?</p>

<doublespend><gambling>
Why can the race between the honest chain and an attacker chain be characterized as a Binomial Random Walk?
Ken
# Why can the race between the honest chain and an attacker chain be characterized as a Binomial Random Walk?

(Asked by: username_0 on 2020-12-18)

I am not familiar with Bitcoin, hope someone can tell me why. Thank you!

Let's consider the following scenario.

The probability of the attacker finds the next block is q and the probability of the honest node finds the next block is p.

Suppose the attacker and the honest node began to find the next block in the meantime (so they spend the same time on finding the PoW solution). If now the attacker finds the next block, since the attacker will not broadcast the block, it won't affect the honest node. The honest node will continue to work on its own PoW. So maybe the probability of the honest node finds the next block is larger than p now (Because the honest node now will spend more time than the attacker on finding the solution of the next block's PoW).
Why can Satoshi consider this catch-up process as the gambler game? Is this just a simplified math model? Or is there any procedure I don't know such that once one node finds the next block, all miners will restart their mining work?

**Tags:** doublespend, gambling


---

## 1 answers

### Answer by username_1 on 2020-12-18. Score: 1

Great question.

So the general gist of 'random walk' is contingent on two different things:

1. Probability
2. Logic

It's better to start with the logic part because it will make the probability portion more logical.

### Looking at the Logic

From the Bitcoin whitepaper, Satoshi states:

> "The race between the honest chain and an attacker chain can be characterized as a Binomial Random Walk. The success event is the honest chain being extended by one block, increasing its lead by +1, and the failiure event is the attacker's chain being extended by one block, reducing the gap by -1."

> "The probability of an attacker catching up from a given deficit is analogous to a Gambler's Ruin problem. Suppose a gambler with unlimited credit starts at a deficit and plays potentially an infinite number of trials to try to reach breakeven."

### Breaking This Down

If we were to consider a miner to be an "attacker" then that means that they must have "reversed" a transaction they spent in order to spend it elsewhere (maybe to a wallet they own).

Using this principle, we know that the transaction **must be in the past**.

So if we're mining at block height 'n', then **at best**, the attacker must start at n-1 (since they need to reverse a transaction that already was mined in a block).

### Here's Where Probability Comes in

As that miner attempts to catch up to the network, they're already at an inherent disadvantage since they're a block behind.

Assuming the network solves for 'n' before the attacker solves 'n-1', then their chances of then solving 'n-1', 'n', then ultimately solving 'n+1' (the new block that the network is working on) decreases substantially.

With this decreased possibility of catching up, the network's probability of extending the lead then increases.

**Formula**

Not sure if this suffices, but Satoshi included both a formula and C code in the original whitepaper.

The formula is as follows:

[![from the bitcoin whitepaper](https://i.sstatic.net/mtMfn.png)](https://i.sstatic.net/mtMfn.png)

[![bitcoin whitepaper excerpt part two](https://i.sstatic.net/SIqD6.png)](https://i.sstatic.net/SIqD6.png)

The C code is as follows:

```

#include "math.h"
#include "stdio.h"

double AttackerSuccessProbability(double q, int z)
{
 double p = 1.0 - q;
 double lambda = z * (q / p);
 double sum = 1.0;
 int i; 
 int k;
 for (k = 0; k <= z; k++)
 {
     double poisson = exp(-lambda);
     
     for (i = 1; i <= k; i++)
     poisson *= lambda / i;
     sum -= poisson * (1 - pow(q / p, z - k));
 }
 return sum;
}

int main()
{
double ans = AttackerSuccessProbability(0.1, 1);
printf("'%f'", ans);
}

```

Hopefully this explanation thus far makes sense (and you find the answer to your question to be adequate)


---

