返回题库

随机游走先到达哪一端

Random Walk

专题
Probability / 概率
难度
L6

题目详情

你在整数轴原点 0,进行对称随机游走:每一步以 1/21/2 概率向左、1/21/2 概率向右。

给定自然数 a>1,b>1a>1,b>1,问:在到达 b-b 之前先到达 aa 的概率是多少?

提示:考虑在停时刻下位置的期望(鞅)。

You are initially located at the origin on the xx-axis. You start a random walk with an equal probability of moving left or right, one step at a time. What is the probability that you will reach point aa before reaching point b-b?

Assume aa and bb are natural numbers. a>1;b>1a >1; b > 1

Hint

Consider the expected value of the position at the end of the game.

解析

答案是

ba+b.\frac{b}{a+b}.

设停时刻 TT 为首次到达 aab-b。对称随机游走的期望位置保持 0,因此

0=E[XT]=aP(XT=a)+(b)P(XT=b).0=E[X_T]=a\cdot P(X_T=a)+(-b)\cdot P(X_T=-b).

解得 P(XT=a)=ba+bP(X_T=a)=\frac{b}{a+b}


Original Explanation

b/(a+b)b/(a+b)

Solution

Probability

Let us assume that we stop walking the moment we reach any of aa or b-b. As we keep walking randomly, we'll eventually hit one of the two points, and the game will surely end.

Suppose PaP_a is the probability that we end at aa, and (1Pa)(1 - P_a) is the probability that we end with b-b.

Let XX be the position on the xx-axis at the end of this game.

E[X]=aPa+(b)(1Pa)E[X] = a \cdot P_a + (-b) \cdot (1 - P_a)

Also note that the walk is symmetric (equal probability in either direction), so, logically, E[X]=0E[X] = 0

0=aPab(1Pa)0 = a \cdot P_a - b \cdot (1 - P_a)

Solve to get Pa=ba+bP_a = \dfrac{b}{a + b}


Follow up Question

What is the expected number of steps to reach either aa or b-b?

Follow up Solution

Warning: This solution uses the knowledge of Martingales and advanced stochastic theory.

In probability theory, a Martingale is a model of a fair game where knowledge of past events does not help to predict the mean of the future winnings, and where the expected value of the next play, given all the plays so far, is the same as the present value, even though the next play could have several possible outcomes.

Formally, the sequence XnX_n is a Martinagle if:

E[Xn+1X1,,Xn]=Xn{E} [X_{n+1}\mid X_{1},\ldots ,X_{n}]=X_{n}

Since we're conducting a random walk, where each step can either be +1+1 (right) or 1-1 (left). This type of problem can be analyzed using a Martingale approach.

Let X1,X2,X3,X_1, X_2, X_3, \ldots be the position on the xx-axis after 1,2,31,2,3\ldots steps.

Here XnX_n is a Martingale because:

E[Xn+1Xn]=0.5(Xn+1)+0.5(Xn1)=XnE[X_{n+1} | X_n] = 0.5(X_{n} + 1) + 0.5(X_n - 1) = X_n

In other words, given we are standing at position XnX_n, the expected value of the next step is the current value.

End Game: Let NN = the number of steps to reach any of aa or b-b starting from position 00. We end the game when we reach either aa or b-b.

XNX_N is either aa or b-b, with probability PaP_a and (1Pa)(1 - P_a) respectively.

Note that E[XN]=0E[X_N] = 0 because we start from 00, and all future expected values are equal to the position. This property can be used to find PaP_a

0=E[XN]=aPab(1Pa)    Pa=ba+b0 = E[X_N] = a \cdot P_a - b \cdot (1 - P_a)\implies P_a = \dfrac{b}{a+b}

We want to calculate E[N]E[N], i.e. the number of steps taken to end the game.

Leap-of-faith: Consider the special variable Yn=(Xn2n)Y_n = (X^2_n - n), what's the expected value in the next step?

E[Yn+1Yn]=E[Xn+12(n+1)Yn]E[Y_{n+1} | Y_n] = E[X^2_{n+1} - (n+1) | Y_n]

=0.5[(Xn+1)2(n+1)]+0.5[(Xn1)2(n+1)]= 0.5 \cdot [(X_{n}+1)^2 - (n+1)] + 0.5 \cdot [(X_{n}-1)^2 -(n+1)]

=Xn2n=Yn= X^2_n-n = Y_n

This satisfies the martingale property!

Hence, at the end of the game, the expected value is: E[YN]=E[Y_N] = The current value of (Xn2n)=020=0(X^2_n - n) = 0^2 -0 = 0 (because no moves have been made yet)

Now, we just expand E[YN]E[Y_N], and we can reach the result with a snap.

0=E[YN]=E[XN2N]=E[XN2]E[N]0 = E[Y_N] = E[X_N^2-N]= E[X_N^2] - E[N]

    0=Paa2+(1Pa)b2E[N]\implies 0 = P_a \cdot a^2 + (1 - P_a) \cdot b^2 - E[N]

    E[N]=ba2a+b+ab2a+b\implies E[N]=\dfrac{b \cdot a^2}{a+b} + \dfrac{a\cdot b^2}{a+b}

    E[N]=ab\implies E[N] = a\cdot b

Hence it takes on average (ab)(a\cdot b) steps to end the game


Notes

  1. If we take Xn=Z1++ZnX_n = Z_1 + \cdots + Z_n where ZiZ_i takes either 1 or -1 with probability 0.5 each, then E[Xn2]=i=1nE[Zi2]+21i<jnE[ZiZj]=n.{\displaystyle E[X_{n}^{2}]=\sum _{i=1}^{n}E[Z_{i}^{2}]+2\sum _{1\leq i<j\leq n}E[Z_{i}Z_{j}]=n.}

  2. Yn=(Xn2n)Y_n = (X^2_n - n) is a commonly used martingale. This can be used to show that the gambler's total gain or loss varies roughly between plus or minus the square root of the number of steps

  3. We do not denote E[Xn]E[X_n] as E[XnX0]E[X_n | X_0] because X0X_0 is not an unknown, it is always zero. But any new knowledge like X1=1X_1 = 1 can impact the expected value, i.e. E[XnX1=1]=X1=1E[X_n | X_1=1] = X_1 = 1

  4. XnX_n is our position after nn steps, while XNX_N is our position at the end of the game.