15251 Some Great Theoretical Ideas i Computer Sciece for "My frieds keep askig me what 251 is like. I lik them to this video: http://youtube.com/watch?v=m275pjvwrli" Probability Refresher What s a Radom Variable? A Radom Variable is a realvalued fuctio o a sample space S E[X+Y] = E[X] + E[Y] Probability Refresher What does this mea: E[X A]? Is this true: Pr[ A ] = Pr[ A B ] Pr[ B ] + Pr[ A B ] Pr[ B ] Similarly: Yes! E[ X ] = E[ X A ] Pr[ A ] + E[ X A ] Pr[ A ] Radom Walks Lecture 13 (February 26, 2008) How to walk home druk 1
Abstractio of Studet Life 0.4 probability No ew ideas Work 0.3 Wait 0.3 Eat 0.01 Solve HW problem Hugry Work 0.99 Abstractio of Studet Life No ew ideas Wait Eat Hugry Work Like fiite automata, but istead 0.4 of a determiisic 0.3 or odetermiistic 0.3 0.01 0.99 actio, we have a probabilistic actio Work Solve HW Example questios: What problem is the probability of reachig goal o strig Work,Eat,Work? Simpler: Radom Walks o Graphs Simpler: Radom Walks o Graphs At ay ode, go to oe of the eighbors of the ode with equal probability At ay ode, go to oe of the eighbors of the ode with equal probability Simpler: Radom Walks o Graphs Simpler: Radom Walks o Graphs At ay ode, go to oe of the eighbors of the ode with equal probability At ay ode, go to oe of the eighbors of the ode with equal probability 2
Simpler: Radom Walks o Graphs Radom Walk o a Lie You go ito a casio with $k, ad at each time step, you bet $1 o a fair game You leave whe you are broke or have $ At ay ode, go to oe of the eighbors of the ode with equal probability 0 Questio 1: what is your expected amout of moey at time t? k Let X t be a R.V. for the amout of $$$ at time t Radom Walk o a Lie You go ito a casio with $k, ad at each time step, you bet $1 o a fair game You leave whe you are broke or have $ 0 k X t = k + δ 1 + δ 2 +... + δ t, (δ i is RV for chage i your moey at time i) E[δ i ] = 0 So, E[X t ] = k Radom Walk o a Lie You go ito a casio with $k, ad at each time step, you bet $1 o a fair game You leave whe you are broke or have $ 0 k Questio 2: what is the probability that you leave with $? Radom Walk o a Lie Questio 2: what is the probability that you leave with $? E[X t ] = k E[X t ] = E[X t X t = 0] Pr(X t = 0) + E[X t X t = ] Pr(X t = ) + E[ X t either] Pr(either) k = Pr(X t = ) + (somethig t ) Pr(either) As t, Pr(either) 0, also somethig t < Hece Pr(X t = ) k/ Aother Way To Look At It You go ito a casio with $k, ad at each time step, you bet $1 o a fair game You leave whe you are broke or have $ 0 k Questio 2: what is the probability that you leave with $? = probability that I hit gree before I hit red 3
Radom Walks ad Electrical Networks What is chace I reach gree before red? Radom Walks ad Electrical Networks Same as voltage if edges are resistors ad we put 1volt battery betwee gree ad red p x = Pr(reach gree first startig from x) p gree = 1, p red = 0 Ad for the rest p x = Average y Nbr(x) (p y ) Same as equatios for voltage if edges all have same resistace! Aother Way To Look At It You go ito a casio with $k, ad at each time step, you bet $1 o a fair game You leave whe you are broke or have $ 0 k Questio 2: what is the probability that you leave with $? voltage(k) = k/ = Pr[ hittig before 0 startig at k]!!! Gettig Back Home Lost i a city, you wat to get back to your hotel How should you do this? Depth First Search! Requires a good memory ad a piece of chalk Gettig Back Home Will this work? Is Pr[ reach home ] = 1? Whe will I get home? What is E[ time to reach home ]? How about walkig radomly? 4
Pr[ will reach home ] = 1 We Will Evetually Get Home Look at the first steps There is a ozero chace p 1 that we get home Also, p 1 (1/) Suppose we fail The, wherever we are, there is a chace p 2 (1/) that we hit home i the ext steps from there Probability of failig to reach home by time k = (1 p 1 )(1 p 2 ) (1 p k ) 0 as k Furthermore: If the graph has odes ad m edges, the E[ time to visit all odes ] 2m (1) Cover Times Cover time (from u) C u = E [ time to visit all vertices start at u ] Cover time of the graph C(G) = max u { C u } (worst case expected time to see all vertices) E[ time to reach home ]is at most this Cover Time Theorem If the graph G has odes ad m edges, the the cover time of G is C(G) 2m ( 1) Actually, we get home pretty fast Chace that we do t hit home by (2k)2m(1) steps is () k Ay graph o vertices has < 2 /2 edges Hece C(G) < 3 for all graphs G 5
A Simple Calculatio True of False: If the average icome of people is $100 the more tha 50% of the people ca be earig more tha $200 each Markov s Iequality If X is a oegative r.v. with mea E[X], the Pr[ X > 2 E[X] ] Pr[ X > k E[X] ] 1/k False! else the average would be higher!!! Adrei A. Markov Markov s Iequality Noeg radom variable X has expectatio A = E[X] A = E[X] = E[X X > 2A ] Pr[X > 2A] + E[X X 2A ] Pr[X 2A] E[X X > 2A ] Pr[X > 2A] (sice X is oeg) Actually, we get home pretty fast Chace that we do t hit home by (2k)2m(1) steps is () k Also, E[X X > 2A] > 2A A 2A Pr[X > 2A] Pr[X > 2A] Pr[ X > k expectatio ] 1/k A Averagig Argumet Suppose I start at u E[ time to hit all vertices start at u ] C(G) Hece, by Markov s Iequality: Pr[ time to hit all vertices > 2C(G) start at u ] So Let s Walk Some Mo! Pr [ time to hit all vertices > 2C(G) start at u ] Suppose at time 2C(G), I m at some ode with more odes still to visit Pr [ have t hit all vertices i 2C(G) more time start at v ] Chace that you failed both times = () 2 Hece, Pr[ havet hit everyoe i time k 2C(G) ] () k 6
Hece, if we kow that Expected Cover Time C(G) < 2m(1) the Pr[ home by time 4k m(1) ] 1 () k Radom walks o ifiite graphs Radom Walk O a Lie Radom Walk O a Lie 0 i Flip a ubiased coi ad go left/right Let X t be the positio at time t Pr[ X t = i ] = Pr[ #heads #tails = i] = Pr[ #heads (t #heads) = i] = t (t+i)/2 /2t Pr[ X 2t = 0] = 2t t 0 i /2 2t ˡ (1/ t) Y 2t = idicator for (X 2t = 0) E[ Y 2t ] = ˡ Z 2 = umber of visits to origi i 2 steps E[ Z 2 ] = E[ t = 1 Y 2t ] ˡ (1/ 1 + 1/ 2 + + 1/ ) = ˡ Sterlig s approx ( ) (1/ t) How About a 2d Grid? I steps, you expect to retur to the origi ( ) times! Let us simplify our 2d radom walk: move i both the xdirectio ad ydirectio 7
How About a 2d Grid? Let us simplify our 2d radom walk: move i both the xdirectio ad ydirectio How About a 2d Grid? Let us simplify our 2d radom walk: move i both the xdirectio ad ydirectio How About a 2d Grid? Let us simplify our 2d radom walk: move i both the xdirectio ad ydirectio How About a 2d Grid? Let us simplify our 2d radom walk: move i both the xdirectio ad ydirectio I The 2d Walk Returig to the origi i the grid both lie radom walks retur to their origis ˡ Pr[ visit origi at time t ] = (1/ t) (1/ t) (1/t) = ˡ But I 3D Pr[ visit origi at time t ] = ˡ (1/ t) 3 = ˡ (1/t 3/2 ) lim E[ # of visits by time ] < K (costat) Hece Pr[ ever retur to origi ] > 1/K E[ # of visits to origi by time ] = ˡ (1/1 + 1/2 + 1/3 + + 1/ ) = ˡ (log ) 8
Druk ma will fid way home, but druk bird may get lost forever Dot Proofs Shizuo Kakutai Prehistoric Uary 1 2 3 4 Hag o a miute! Is t uary too literal as a represetatio? Does it deserve to be a abstract represetatio? It s importat to respect each represetatio, o matter how primitive Uary is a perfect example Cosider the problem of fidig a formula for the sum of the first umbers You already used iductio to verify that the aswer is (+1) 9
1 + 2 + 3 + + 1 + = S 1 + 2 + 3 + + 1 + = S + 1 + 2 + + 2 + 1 = S + 1 + 2 + + 2 + 1 = S +1 + +1 + +1 + + +1 + +1 = 2S S = (+1) 2 (+1) = 2S S = (+1) 2 There are (+1) dots i the grid! (+1) = 2S....... 2 1 1 2........ th Triagular Number = 1 + 2 + 3 +... + 1 + = (+1)/2 th Square Number = 2 = + 1 1 Breakig a square up i a ew way Breakig a square up i a ew way 10
1 + 3 Breakig a square up i a ew way 1 + 3 + 5 Breakig a square up i a ew way 1 + 3 + 5 + 7 Breakig a square up i a ew way 1 + 3 + 5 + 7 + 9 Breakig a square up i a ew way The sum of the first odd umbers is 2 1 + 3 + 5 + 7 + 9 = 5 2 Breakig a square up i a ew way Pythagoras 11
th Square Number Here is a alterative dot proof of the same sum. = + 1 = 2 th Square Number th Square Number = + 1 = + 1 = 2 th Square Number = + 1 = Sum of first odd umbers Check the ext oe out 12
Area of square = ( ) 2 Area of square = ( ) 2 1 1 Area of square = ( ) 2 Area of square = ( ) 2 1? 1 1 1? Area of square = ( ) 2 Area of square = ( ) 2 = (1 ) 2 + 1 + = (1 ) 2 + (1 + ) = (1 ) 2 + ( ) 1 1 = (1 ) 2 + 3 1 1 (1 ) 2 1 13
( ) 2 = 3 + (1 ) 2 = 3 + (1) 3 + (2 ) 2 = 3 + (1) 3 + (2) 3 + (3 ) 2 = 3 + (1) 3 + (2) 3 + + 1 3 ( ) 2 = 1 3 + 2 3 + 3 3 + + 3 = [ (+1)/2 ] 2 Radom Walk i a Lie Cover Time of a Graph Markov s Iequality Here s What You Need to Kow Dot Proofs 14