8
$\begingroup$

As explained here, the average distance or 'travel' of a random walk with $N$ coin tosses approaches: $$\sqrt{\dfrac{2N}{\pi}}$$

What a beautiful result - who would've thought $\pi$ was involved! However, what would be the formula to use for an arbitrary paytable?

For example, a coin toss has the paytable:

  • 0.5 : -1
  • 0.5 : 1

...so a 50% chance of both winning or losing a point. After 10,000 coin tosses, the travel on average will be $\sqrt{10000\cdot2/{\pi}} \approx 79.788$.

However a dice roll where you need to land a six to win could have the paytable:

  • 0.8333.. : -1
  • 0.1666.. : 5

After 10,000 dice rolls, the travel on average will be about 178. However, I only know that because I used simulation to brute force the result - I don't know the formula.

More generally, a paytable could have multiple entries where all the probabilities add up to one:

  • probability1 : payout1
  • probability2 : payout2
  • probability3 : payout3
  • ...
  • ...
  • probabilityN : payoutN

Note that the total of the payouts may not necessarily be zero. It could be weighted to produce an unfair game. For example:

  • 0.75 : -1
  • 0.1 : 0.5
  • 0.15 : 4.5

That's an average payout of $-0.025$ with a variance of $3.811875$, and using simulation, I get $\approx 268.8$ 'travel' from 10000 runs. But how would I find this out directly?

In other words, how would you find the average 'travel' of such a generalized paytable without resorting to simulation? As a side question, would this figure also be a better indication of risk for such a 'game' compared to the standard deviation of the paytable as defined here?

Here's the code I used for the simulation: http://pastebin.com/985eDTFh

It's written in C#, but is otherwise very well self-contained. Most of it is a fast random class, but you can use the default Random class if you prefer. Also, if you're not using C#, don't worry too much about converting the convertCSVtoPayoutTable() function as you can hard code the probability and payout arrays yourself if you prefer.

$\endgroup$
16
  • 3
    $\begingroup$ In full generality, the asymptotics is $\sqrt{2\sigma^2N/\pi}$ where $\sigma^2$ is the variance of a single step. In your dice example, $\sigma^2=5$ hence, for $N=10'000$, $\sqrt{2\sigma^2N/\pi}=100\sqrt{10/\pi}=178.4124116...$ $\endgroup$
    – Did
    Commented Aug 17, 2015 at 11:26
  • $\begingroup$ But you have already been explained that, no? $\endgroup$
    – Did
    Commented Aug 17, 2015 at 11:29
  • $\begingroup$ @Did: Thanks for the feedback. Your formula works for the coin and dice rolls, but when I tried for three entries or more, it differs from the simulation. An example is: probabilities = [0.75, 0.1, 0.15] and payout = [-1, 0.5, 4.5]. That's a variance of 3.811875, but the average 'travel' according to your formula is 155.779 (to 3dp), whilst I get approx 268.8. Could you check your formula? $\endgroup$
    – Dan W
    Commented Aug 17, 2015 at 14:27
  • 1
    $\begingroup$ Your example is not centered, thus the asymptotics scales like $N$ instead of $\sqrt{N}$, and CLT and variance become irrelevant. $\endgroup$
    – Did
    Commented Aug 17, 2015 at 15:05
  • $\begingroup$ @Did: Ah, in that case, can you give me the new revised formula which takes into account non-centered paytables? $\endgroup$
    – Dan W
    Commented Aug 17, 2015 at 15:07

1 Answer 1

2
+25
$\begingroup$

Elaborating on the comments, here is an answer to your question. Basically all the confusion lies in the difference between expected value and expected distance- at least it did for me. For a distribution centred at the origin, this difference is huge, and for large $N$ tends towards:

$$\sqrt{\dfrac{2\sigma^2 N}{\pi}}$$

This is clearly a lot bigger than the expected value, which is $0$. This makes sense, intuitively, if you draw out a normal distribution. Note that because you are adding random independent variables with a well-defined mean and variance it's OK to make the assumption of an approximate normal distribution, by the central limit theorem. The approximation gets better with $N$. Now, values cancel out in this normal distribution, leaving a mean of $0$, but distances don't. See the lines in red in the below image- these are distances- they both contribute positively towards expected distance.

Normal centred at 0

OK, but what if the distribution is shifted? What does this do to the average distance? What it does is it makes it much closer to the average value. The reason is that the further you shift, left or right, the tinier the remainig positive/negative tail becomes. Hence the average distance and the average value tend towards the same thing. See the image below for what I'm talking about. In the calculation for expected value, the red shaded part cancels out its corresponding tail on the other side. In the calculation for expected distance on the other hand, the red shaded part contributes positively towards the total distance. But it's so tiny that the difference is negligible the further the distribution is shifted. This explains the tiny discrepancy between your observed $263$ and the actual mean of $250$. It makes sense: the absolute average distance must be greater than the mean, because there is no "cancelling out" of tails.

Shifted Distribution

To be more formal about the whole thing, let's write some formulas. The expected distance is

$$E(|x|) = \lim_{n\rightarrow\infty}\dfrac{\sum_{i = 1}^n |x_i|}{n}$$

Whereas the expected value is:

$$E(x) = \lim_{n\rightarrow\infty} \dfrac{\sum_{i = 1}^n x_i}{n}$$

Here $x_i$ is just an observation after you run the experiment for the $i^{th}$ time. Also $n$ is the number of experiments. It's different to $N$, the number of steps (dice rolls) per experiment. Now, let Let $U$ be the bag (set with multiplicity) of values $u_i$ in the observed sample set that are positive. And let $V$ be the bag of values $v_i$ that are negative. Then we can also express expected value as follows:

$$E(x) = \lim_{n\rightarrow\infty} \dfrac{\sum_{u_i \in U} |u_i| - \sum_{v_i \in V} |v_i|}{|U| + |V|}$$

Note that $n$ is just the number of experiments/trials and $|U| + |V| = n$. Now, the expected distance is:

$$E(|x|) = \lim_{n\rightarrow\infty} \dfrac{\sum_{u_i \in U} |u_i| + \sum_{v_i \in V} |v_i|}{|U| + |V|}$$

The only difference is a plus sign. Clearly then, as either $U$ or $V$ dominates because of a sliding mean, $E(|x|)$ tends towards $|E(x)|$, with a small error term. The error term will correspond to the leftover (smaller) tail of the distribution on either the positive or negative axis. Without loss of generality, let's say there are more negative than positive values i.e. the positive tail is shorter. Then explicitly, the error term is:

$$E(|x|) - |E(x)| = \lim_{n\rightarrow\infty} \dfrac{2\sum_{u_i \in U} |u_i|}{n}$$

When the mean is $0$, this error term is maximised at:

$$\sqrt{\dfrac{2\sigma^2 N}{\pi}}$$

But as you can see from the shape of the normal curve, it rapidly decreases. This agrees with your observation, with an error term of only around $13$. Of course, I realise that this doesn't answer the question, as I haven't given an explicit formula for the error term! But I believe this answer has enough intuitive value to explain your observed results.

$\endgroup$
18
  • $\begingroup$ I plugged in the numbers $-0.025*10000 + \sqrt{2*3.811875*10000/\pi}$ but got apx 94 (or -405 if I tried using negative instead of positive between the terms). I expected 268.8 (or -268.8) as I detailed in my question. Where I have gone wrong? I presume $\sigma^2$ = 3.811875. $\endgroup$
    – Dan W
    Commented Sep 17, 2015 at 17:43
  • $\begingroup$ Maybe you have not gone wrong. Maybe I have gone wrong. I will flag this to the expert Did in the comments above, if he is not too exasperated hopefully he will have an insight. $\endgroup$ Commented Sep 18, 2015 at 10:39
  • $\begingroup$ After a finite number of runs $N$ the result is random. Loosely speaking, the CLT describes the limit of the probability that this random result $X_N$ is around its expectation $E(X_N)=\mu N$ in the $\sqrt{N}$ scale. More rigorously, consider the event $A_N=[\mu N+a\sqrt{2\sigma^2N/\pi}<X_N<\mu N+b\sqrt{2\sigma^2N/\pi}]$, then the CLT asserts that $P(A_N)$ converges to some $p$ in $(0,1)$ when $N\to\infty$, where $p=P(a<Z<b)$ for some standard normal random variable $Z$. Note that, formally, CLT says nothing about the discrepancy between $P(A_N)$ and $p$ when $N$ is large ... $\endgroup$
    – Did
    Commented Sep 18, 2015 at 10:54
  • 1
    $\begingroup$ @DanW: First of all, this question is not bounty worthy. I didn't answer your question, so I don't get the bounty. Please do not falsely award it to me. Secondly, I am a computer programmer. I asked my stat friend to look at this but she is busy at the moment (PhD woes). As for the formula... I haven't given you a closed form. But if you modify your computer program to count only positive values, then divide by $10000$, you should get $9.4$ (half of $18.8$) according to my non-closed-form formula. I would love to see the result! $\endgroup$ Commented Sep 24, 2015 at 11:53
  • 1
    $\begingroup$ Sure. Here you go: pastebin.com/985eDTFh - Don't worry about the size - three quarters of it is code for a fast random class I pinched from Stackoverflow. You can use the default Random class if you prefer. Also, if you're not using C#, don't worry too much about converting the convertCSVtoPayoutTable() function as you can hard code the probability and payout arrays yourself if you prefer. $\endgroup$
    – Dan W
    Commented Sep 25, 2015 at 17:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .