# Probability and game

This should be known as "gambler's ruin". In a game, at each step, you can win 1\$or lose 1\$. Let $Z_i$ be a variable that can assume as values 1 or -1. Let $$X_n=\sum_{i=0}^n Z_i .$$

Can you show me in details how to calculate $P(X_n \geq a)$ for a certain $a>0$? I thought that it was the case to use the cumulative binomial distribution, but I tried to compare my results with the data I have and they did not match.

As second question, I would appreciate just a little hint on how to compute that probability with excel.

-
I saw your flag that you wanted to delete this question. I wanted to make the point that this site helps everyone online - even though you've got the answer now, if someone had the same question as you, we'd want them to be able to see the answer here as well. Also, you can write up your solution as an answer; this is explicitly encouraged by the SE network of sites. See here and here. – Zev Chonoles Jun 28 '12 at 15:25

You do want to use the binomial distribution. If you have probability $p$ of winning and $1-p$ of losing on each of $n$ games, then $W$, the number of times you win, is

$$W\sim B(n,p)$$

which is equivalent to saying that

$$P(W=w) = {n\choose w}p^w(1-p)^{n-w}$$

This is related to $X$ by the formula

$$X=W-(n-W)=2W-n$$

which gives you

$$P(X=x)=P(2W-n=x)=P(W=(x+n)/2)={n\choose m} p^m(1-p)^{n-m}\quad\textrm{ where }m=(x+n)/2$$

To compute $P(X>a)$ you simply sum:

$$P(X>a) = \sum_{x>a}P(X=x)$$

-

It is indeed a binomial distribution if the $Z_i$s are independent bernoulli variables. You should just sum from a to n to get $P(X_n\geq a)$.

EDIT : see my comment below for excel and @Chris Taylor answer for the math.

-
The $Z_i$ aren't quite bernoulli. A bernoulli rv takes values 0 or 1, whereas here the $Z_i$ take values -1 or 1. – Chris Taylor Jun 26 '12 at 8:31
Sorry for that, I read the problem to quickly. I shall just add for clarity that you need to have x+n even to get non-zero values in the formula above. – David Jun 26 '12 at 8:47
On excel, depending on the value of a and n it is equivalent to the survival of a binomial distribution but not in a. If you want $P(X\geq a)$ and not $P(X>a)$ you can use : if $(a+n)/2$ even then $P(X\geq a)$ = 1-BINOMDIST((a+n)/2-1,n,p,TRUE) and if $(a+n)/2$ odd then something like 1-BINOMDIST(TRUNC((a+n)/2),n,p,TRUE). I didn't check this so it is subject to errors. – David Jun 26 '12 at 9:13