



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




CS787: Advanced Algorithms Scribe: Blayne Field Lecturer: Shuchi Chawla Topic: Random Walks and Markov Chains Date: November 26, 2007
As we have seen in the course up to this point, randomization has been a useful tool for developing simple and efficient algorithms. So far, most of these algorithms have used some sort of independent coin tosses. In this lecture, we started looking at choosing a sample from a large space, with our choices being dependent on previous choices. We looked at this concept through the framework of random walks and Markov chains.
Definition 27.1.1 A random walk is a process in which at every step we are at a node in an undirected graph and follow an outgoing edge chosen uniformly at random. A Markov chain is similar, except the outgoing edge is chosen according to an arbitrary distribution.
Random walks can occur in many situations, and are useful for analyzing various scenarios. Con- sider the following betting game: a player bets $1, and either loses it or wins an addition dollar with probability 12. Since the probability of either thing happening is equal, we can think of this as a random walk on a line graph, where each node represents the amount of wealth at any point of time. This allows us to learn about numerous aspects of the game, such as the probability distribution of the amount of money at a given time. We can also ask about the probability of the player running out of money before winning a certain amount, and if that happens, what is the expected amount of time before that happens.
Another situation where random walks occur is shuffling a deck of cards. One possible way of drawing a permutation u.a.r. is to start at an arbitrary permutation and apply a local shuffling operation multiple times. This can be thought of as a random walk on a graph of all permutations. Our graph would contain nodes for each of the 52! permutations, and the connectivity of the graph would be determined by what local operations are allowed. For example, if we could just randomly choose 1 card, and move it to the top, each node would have degree 52 (if we include self-loops). Analyzing this random walk may allow us to determine how many local steps we would need to take in order to be reasonably close to the uniform distribution.
There are numerous properties of random walks that we may be interested in. They are listed and defined informally below: Stationary distribution: what is the distribution of our current location if we run the random walk for an infinite number of steps. Hitting time: denoted huv is the expected time to get from u to v.
Commute time: denoted Cuv is the expected time to get from u to v, and back to u Cover time (starting at u): denoted Cu is the expect time to visit every node (starting at node u) Cover time (for a graph): denoted C(G) = maxu Cu.
A random walk (or Markov chain), is most conveniently represented by its transition matrix P. P is a square matrix denoting the probability of transitioning from any vertex in the graph to any other vertex. Formally, Puv = Pr[going from u to v, given that we are at u]. Thus for a random walk, Puv = (^) d^1 u if (u, v) ∈ E, and 0 otherwise (where du is the degree of u). Thus for the example graph given below the transition matrix would be:
1 3 0 0
1 3
1 1 3 3 0 0
1 3
1 1 3 4
1 4
1 4 0
1 4 0 13 13 13 0
Thus if we have a distribution π over the nodes, we can obtain the distribution after one step by computing π′^ = P T^ ·π. Using this definition, we can define a stationary distribution πs as a distribu- tion with the property that P T^ · πs = πs. Stationary distributions are not always unique, but under certain conditions, they are. It also is the case that under certain conditions, limt→∞(P T^ )tπ = πs for all starting distributions π. We will discuss these conditions in the next lecture.
For the following examples, consider a graph G = (V, E), with n = |V | and m = |E|. Let du denote the degree of vertex u.
Lemma 27.4.1 πv = 2 dmv is a stationary distribution for G
Proof: (P T^ · π)u =
v Pvuπv^ =^
v:(v,u)∈E
dv 2 m ∗^
1 dv =^
v:(v,u)∈E
1 2 m =^ πu^ (because^ Pvu^ =^
dv 2 m if (v, u) ∈ E and 0 otherwise).
It turns out that for some graphs, the bound given in lemma 27.6.1 is tight. One example of this is the line graph with n vertices, depicted below (Ln). According to the lemma, C(G) ≤ 2(n − 1)^2 = O(n^2 ). Also, we can note that h 1 , 0 ≤ 2(n − 1) − 1, since h 0 , 1 = 1, and Cuv = huv + hvu by linearity of expectation. We will show in the next lecture that the cover time for this graph is indeed Θ(n^2 ).
However, the bound is not always tight, as in the case of the complete graph, Kn. In this case, m = n(n 2 − 1), so C(Kn) = O(n^3 ) by the lemma. However, we can get a much tighter bound on the cover time for this graph. Since in the complete graph, we can go from any node to any other in one step, the problem of visiting all nodes can be viewed as an instance of the coupon collector problem. As we saw in a previous lecture, this would give us a bound of O(n log n).
One last example is the lollipop graph (pictured below) , which has n vertices, half of which form K n 2 , with the remainder forming L n 2 (and attached to the complete graph portion). The lemma
in this case gives C(G) = O(n^3 ), which happens to be tight. This is because it takes Ω(n^3 ) time to get from u to v. We can see this by the following analysis: for just the line graph, it should take Ω(n^2 ) steps, Ω(n) of which will be spent at u, since the nodes should approach a uniform distribution. However, if we are at u, there is a (^2) n probability of leaving the clique, see we need to visit u Ω(n) times to ’escape’ back to the line graph. However, if we are in the clique portion it takes Ω(n) steps to get back to u. Thus each time we end up in u from the line graph, we expect to take Ω(n^2 ) steps to get back into the line graph. Thus the expected number of steps is Ω(n^3 ). This illustrates that the number of edges doesn’t always give the best estimate, since both this and the last example had O(n^2 ) edges.
Since any graph has at most O(n^2 ) edges, the cover time is O(n^3 ) for any graph. Thus we can use random walks to test for s-t connectivity using very smalls amounts of space. This problem can be solved using either BFS or DFS, but they use Ω(n) space. This bound on the cover time suggests a simple randomized algorithm for testing s-t connectivity. We just run a random walk starting at s for 2n^3 steps and output ’connected’ if we ever encounter t on our walk. This algorithm will succeed with probability 12 , so if we desired gives an upper bound on the expected time of our algorithm, and allows us to use log n bits to store our current location in the walk, and O(log n)
bits as a counter for our time in the walk. This shows that s − t connectivity can be solved in randomized log space. It was recently shown that the procedure can be derandomized, while still still using logarithmic space.