# Variance equations that yield inconsistent results

Consider a game of chance were a player places a bet, and coin is flipped if the coin lands on heads the player wins $$2b$$ where $$b$$ is the bet value. If the coin lands on tails the player looses the bet. $$E[V] = \mu= 1$$ for this game, where $$V$$ is the random amount we win. The $$\sigma^2 = 2.5$$ for a bet of 1 according to the following equation: $$\sigma^2 = \sum p_i(x_i-\mu_x)^2 = \frac{1}{2}(2-\mu)^2 + \frac{1}{2}(-1 -\mu)^2$$

How ever simulations have shown a convergence to $$\sigma^2 = 1$$ or more generally $$\sigma^2$$ converges according to (in the simulations):

$$\sigma^2 = \frac{1}{2}(2-\mu)^2 + \frac{1}{2}(-\mu)^2$$

Where $$w$$ is the winning value and $$b$$ is the bet value. This is inconsistent and I'm sure i'm going wrong somewhere. Most probably in the way I'm calculating the actual variance. But I'm not sure how. Please can someone point out what I'm doing wrong and what would be the correct way.

The equations used in the simulation are as follows:

Equation used in computing the mean $$\overline{x}=\frac{1}{n}\sum_{i=1}^{n}{\frac{w_i}{b_i}}$$ Where $$\overline{x}$$ is the actual mean, $$n$$ is the number of trials or rounds(flips), $$w_i$$ is the winning value of a flip on round $$i$$. $$b_i$$ is the bet placed on round $$i$$.

Equation used in computing the actual variance $$\overline\sigma^2 = \frac{\sum_{i=1}^{n}{(\frac{w_i}{b_i})^2}}{n}-\overline{x}^2$$

Where $$\overline\sigma^2$$ is the actual variance, $$n$$ is the number of trials or rounds(flips), $$w_i$$ is the winning value of a flip on round $$i$$. $$b_i$$ is the bet placed on round $$i$$ and $$\overline{x}$$ is the actual mean as calculated above.

Note: The equation for calculating the actual variance is derived from the equation $$\sigma^2 = \sum(x_i-\mu_x)^2$$ as to eliminate the need for the simulator to store a history of each rounds bet and winning values.

• I don't understand your first equation. Either $x_i$ is the net gain and is equal to either $-1$ or $1$ (and then $\mu = 0$), or $x_i$ is the winnings and is equal to either $0$ or $2$ (and then $\mu = 1$). But it seems as though you have $x_i$ equal to either $2$ or $-1$ with equal likelihood, but $\mu = 1$. – Brian Tung Jan 24 at 0:44
• I also don't understand the calculation of the mean. As I understand the game, if I bet $1$ then, with equal probability, I win $2$ or lose $1$. Thus my expected gain is $\frac 12\times 2-\frac 12\times 1=1-\frac 12=\frac 12$. No? If I have the payouts wrong, please state the correct ones clearly. – lulu Jan 24 at 0:50
• $x_i$ is amount won or lost as described on stat.yale.edu/Courses/1997-98/101/rvmnvar.htm and numerous other sources. Scroll down to the section of variance it's described in more detail (I was trying to avoid posting links as links can be broken). The value of $\mu = 1$ is calculated using $\overline{\mu}=\frac{1}{m}\sum f_ix_i$ where $m$ is the number of possible positions or outcomes, $f_i$ is the number of positions with a specific winning outcome & $x_i$ is the multiplier of the bet for that outcome. In our case $m = 2$ for two possible outcomes, $f_i = 1$ and $x_i = 2$. – MSD Jan 24 at 0:59
• $i\in W$ where $W$ is all possible winning outcomes – MSD Jan 24 at 1:00
• So, what exact calculation do you do? In your post you say that the possible outcomes are $2,-1$. In your comment you say $2,1$ which I assume is a typo. Sticking with $2,-1$, don't you get the value $\frac 12$? Your proposed mean $\mu=1$ is quite a lot closer to $2$ then it is to $-1$. Phrased differently, I assume you disagree with the calculation I gave in my first comment, since you claim a different result. What part of my calculation is incorrect? – lulu Jan 24 at 1:05

Clear and precise notation is necessary, and you have made certain claims but then allow the notation to obfuscate the meaning.

Define $$X_1, X_2, \ldots,$$ to be a sequence of independent and identically distributed Bernoulli random variables, each with $$\Pr[X_i = 1] = p$$ for $$i = 1, 2, \ldots$$, and that $$X_i = 1$$ if the outcome of the $$i^{\rm th}$$ toss corresponds to a win.

The expected value of the outcome of a single toss is $$\operatorname{E}[X_i] = p$$. The variance of the outcome of a single toss is $$\operatorname{Var}[X_i] = p(1-p).$$ This much should not be in question.

If the bet amount is $$b$$ for each toss, then define the random variable $$Y_i = (3X_i - 1)b = \begin{cases} 2b, & X_i = 1 \\ -b, & X_i = 0. \end{cases}$$ You may easily verify by substitution that this is true. Then $$\operatorname{E}[Y_i] = \operatorname{E}[(3X_i-1)b] = \operatorname{E}[3X_i - 1]b = \left(\operatorname{E}[3X_i] - 1\right)b = (3 \operatorname{E}[X_i] - 1)b = (3p-1)b.$$ The variance is $$\operatorname{Var}[Y_i] = b^2 \operatorname{Var}[3X_i - 1] = b^2 \operatorname{Var}[3X_i] = 9b^2 \operatorname{Var}[X_i] = 9b^2 p(1-p).$$ Again, these are for a single toss, for some general fixed win probability parameter $$p \in [0,1]$$ and fixed ante $$b$$.

If we set $$p = 1/2$$ so the coin is fair, and $$b = 1$$, the expected value of the random amount won in a single toss is simply $$\operatorname{E}[Y_i] = (3(1/2)-1)(1) = 1/2$$, and the variance of the random amount won in a single toss is $$\operatorname{Var}[Y_i] = 9(1^2)(1/2)(1 - 1/2) = 9/4$$. This is not, as you claim, $$\mu = 1$$ and $$\sigma^2 = 2.5 = 5/2$$, as you apparently have not considered that the loss of ante represents a negative outcome for the random variable $$Y_i$$.

If, however, you are not concerned about the loss of ante--in other words, bets are risk free, then you can easily define another set of random variables, say $$W_i = 2bX_i,$$ that simply represents the winnings irrespective of losses--so in particular, $$W_i = 0$$ if $$X_i = 0$$ and the ante is not taken (which does not really amount to a bet). Then $$\operatorname{E}[W_i] = 2bp$$ and $$\operatorname{Var}[W_i] = 4b^2 p(1-p)$$ and this is neither difficult nor very interesting to analyze. For $$b = 1$$ and $$p = 1/2$$ you get $$\operatorname{E}[W_i] = 1$$ and $$\operatorname{Var}[W_i] = 1$$, so even in this case, your calculations of the mean and variance are inconsistent.

For a sample of fixed size $$n$$, the net winnings is $$S_Y = \sum_{i=1}^n Y_i$$ and the total amount won, ignoring losses, is $$S_W = \sum_{i=1}^n W_i.$$ The sample means of the net winnings and total amount won ignoring losses, are $$\bar Y = \frac{S_Y}{n} = \frac{1}{n} \sum_{i=1}^n Y_i, \quad \bar W = \frac{S_W}{n} = \frac{1}{n}\sum_{i=1}^n W_i,$$ respectively. The expected values and variances of these random variables are, by linearity of expectation and linearity of independent variances, $$\operatorname{E}[S_Y] = n\operatorname{E}[Y_i] = (3p-1)nb, \quad \operatorname{E}[S_W] = n\operatorname{E}[W_i] = 2npb, \\ \operatorname{Var}[Y_i] = n\operatorname{Var}[Y_i] = 9b^2 np(1-p), \quad \operatorname{Var}[W_i] = n\operatorname{Var}[W_i] = 4b^2 np(1-p), \\ \operatorname{E}[\bar Y] = \operatorname{E}[S_Y/n] = \operatorname{E}[Y_i], \quad \operatorname{E}[\bar W] = \operatorname{E}[W_i], \\ \operatorname{Var}[\bar Y] = \operatorname{Var}[S_Y/n] = \operatorname{Var}[Y_i]/n, \quad \operatorname{Var}[\bar W] = \operatorname{Var}[S_W/n] = \operatorname{Var}[W_i]/n.$$

If you are not getting these results via simulation, your simulation is done improperly or you are computing the wrong statistic from your simulations, or you are interpreting the results incorrectly. I cannot speak to how you have implemented such a simulation. One rather obvious mistake, however, is that you seem to be using formulas without really understanding what they are for, what they represent, and how they apply to your problem; because you have not properly explained where they came from nor justified their use.