Mathematics for Computer Science Graph with probable transitions MIT 6.042J/18.062J 4/7 1/6 Random Walks 4/9 1/6 1/7 2/7 3/5 2/3 5/9 2/5 Copyright ©Albert R. Meyer, 2005. December 14, 2005 lec 15w.1 Copyright ©Albert R. Meyer, 2005. Graph with probable transitions December 14, 2005 lec 15w.3 Applications • Finance – Stocks, options • Algorithms – web search, clustering • Physics – Brownian Motion Copyright ©Albert R. Meyer, 2005. 1-Dimensional Walk December 14, 2005 lec 15w.4 Gambler’s Ruin " " lec 15w.2 Random Walks Questions • Pr{blue reaches orange before green} • Pr{blue ever reaches orange} • E[#steps blue to orange] • Average fraction of time at blue Copyright ©Albert R. Meyer, 2005. December 14, 2005 p T $$$ q Gambler’s Ruin n 0 Copyright ©Albert R. Meyer, 2005. December 14, 2005 lec 15w.5 Copyright ©Albert R. Meyer, 2005. # of bets December 14, 2005 lec 15w.6 1 Gambler’s Ruin Gambler’s Ruin Parameters: Three general cases: n ::= initial capital (stake) T ::= gambler’s Target p ::= Pr{win $1 bet} q ::=1– p m ::= intended profit = T – n Copyright ©Albert R. Meyer, 2005. • Biased against • Biased in favor • Unbiased (Fair) lec 15w.7 December 14, 2005 Fair Case: p = q = 1/2 Copyright ©Albert R. Meyer, 2005. Let w ::= Pr{reach Target} E[$$] = w·(T – n) + (1 – w)·(–n) = wT – n But game is fair, so E[$$ won] = 0 Copyright ©Albert R. Meyer, 2005. lec 15w.9 December 14, 2005 Copyright ©Albert R. Meyer, 2005. December 14, 2005 lec 15w.10 Biased Against: p < 1/2 < q Consequences n=500, T=600 Pr{win $100} = 500/600 ≈ 0.83 Betting red in US roulette p = 18/38 = 9/19 < 1/2 n=1,000,000, T=1,000,100 Pr{win $100} ≈ 0.9999 December 14, 2005 n w= T n T Fair Case Copyright ©Albert R. Meyer, 2005. lec 15w.8 December 14, 2005 Fair Case: p = q = 1/2 Let w ::= Pr{reach Target} w= p < 1/2 p > 1/2 p = 1/2 lec 15w.11 Copyright ©Albert R. Meyer, 2005. December 14, 2005 lec 15w.12 2 Biased Against: p < 1/2 < q Biased Against: p < 1/2 < q Astonishing Fact! Pr{win $100 starting with $500} < 1/37,000 ! More amazing still! Pr{win $100 starting with $1M} < 1/37,000 Pr{win $100 starting w/ any $n stake} (was 5/6 in the unbiased case.) Copyright ©Albert R. Meyer, 2005. December 14, 2005 lec 15w.13 Winning in the Unfair Case < 1/37,000 Copyright ©Albert R. Meyer, 2005. lec 15w.14 December 14, 2005 Winning in the Unfair Case Team Problem: for p < q, for p < q: ⎛ p⎞ ⎜ ⎟ ⎝q⎠ m is exponentially decreasing in m, where m ::= T−n = intended profit Copyright ©Albert R. Meyer, 2005. December 14, 2005 the intended profit. lec 15w.18 Copyright ©Albert R. Meyer, 2005. Losing in Roulette December 14, 2005 lec 15w.19 Losing in Roulette p = 18/38, q = 20/38 Copyright ©Albert R. Meyer, 2005. December 14, 2005 lec 15w.20 Copyright ©Albert R. Meyer, 2005. December 14, 2005 lec 15w.21 3 Gambler’s Ruin Gambler’s Ruin T T T-n $$$ $$$ n 0 0 # of bets Copyright ©Albert R. Meyer, 2005. December 14, 2005 lec 15w.22 pr{lose starting with $n} = pr{win starting with $(T - n)} T −n T Copyright ©Albert R. Meyer, 2005. December 14, 2005 lec 15w.23 Fair Case for T = ∞ Fair Case = # of bets Copyright ©Albert R. Meyer, 2005. Pr{lose starting with n | T = ∞} ≥ Pr{lose starting with n | T < ∞} T −n →∞ as T → ∞ = T So if the gambler keeps betting, he is sure to go broke. December 14, 2005 lec 15w.24 Copyright ©Albert R. Meyer, 2005. December 14, 2005 lec 15w.25 How Many Bets? Return to the origin. What is the expected number of bets for the game to end? – either by winning $(T-n) or by going broke (losing $n). If you start at the origin and move left or right with equal probability, and keep moving in this way, Pr{return to origin} = 1 Copyright ©Albert R. Meyer, 2005. December 14, 2005 lec 15w.26 Copyright ©Albert R. Meyer, 2005. December 14, 2005 lec 15w.27 4 How Many Bets? Fair Case Fair Case for T = ∞ E[# bets] = n(T−n) = (initial stake)⋅(intended profit) proof by solving linear recurrence: en = p(1 + en+1) + q(1 + en-1) Copyright ©Albert R. Meyer, 2005. December 14, 2005 lec 15w.30 Likewise, E[#bets for T = ∞] ≥ E[#bets for T < ∞] = n(T-n) → ∞ (as T → ∞) So the expected #bets to go broke is infinite! Copyright ©Albert R. Meyer, 2005. December 14, 2005 lec 15w.31 Team Problems Problems 1−3 Copyright ©Albert R. Meyer, 2005. December 14, 2005 lec 15w.32 5