Random Walks and Markov Chains Nimantha Thushan Baranasuriya Girisha Durrel De Silva Rahul Singhal Karthik Yadati Ziling Zhou.

Slides:



Advertisements
Similar presentations
Completeness and Expressiveness
Advertisements

Discrete time Markov Chain
Ch 3.2: Solutions of Linear Homogeneous Equations; Wronskian
Boyce/DiPrima 9th ed, Ch 2.8: The Existence and Uniqueness Theorem Elementary Differential Equations and Boundary Value Problems, 9th edition, by William.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Chapter 4. Discrete Probability Distributions Section 4.11: Markov Chains Jiaping Wang Department of Mathematical.
Chapter 2 Concepts of Prob. Theory
Gibbs sampler - simple properties It’s not hard to show that this MC chain is aperiodic. Often is reversible distribution. If in addition the chain is.
Generating Hard Satisfiability Problems1 Bart Selman, David Mitchell, Hector J. Levesque Presented by Xiaoxin Yin.
The Theory of NP-Completeness
Properties of SLUR Formulae Ondřej Čepek, Petr Kučera, Václav Vlček Charles University in Prague SOFSEM 2012 January 23, 2012.
COUNTING AND PROBABILITY
1 The Monte Carlo method. 2 (0,0) (1,1) (-1,-1) (-1,1) (1,-1) 1 Z= 1 If  X 2 +Y 2  1 0 o/w (X,Y) is a point chosen uniformly at random in a 2  2 square.
IERG5300 Tutorial 1 Discrete-time Markov Chain
Markov Chains 1.
Algebra Problems… Solutions Algebra Problems… Solutions © 2007 Herbert I. Gross Set 22 By Herbert I. Gross and Richard A. Medeiros next.
The Rate of Concentration of the stationary distribution of a Markov Chain on the Homogenous Populations. Boris Mitavskiy and Jonathan Rowe School of Computer.
Андрей Андреевич Марков. Markov Chains Graduate Seminar in Applied Statistics Presented by Matthias Theubert Never look behind you…
Entropy Rates of a Stochastic Process
6.896: Probability and Computation Spring 2011 Constantinos (Costis) Daskalakis lecture 2.
Markov Chains & Randomized algorithms BY HAITHAM FALLATAH FOR COMP4804.
Complexity 26-1 Complexity Andrei Bulatov Interactive Proofs.
. PGM: Tirgul 8 Markov Chains. Stochastic Sampling  In previous class, we examined methods that use independent samples to estimate P(X = x |e ) Problem:
1 Boolean Satisfiability in Electronic Design Automation (EDA ) By Kunal P. Ganeshpure.
Algorithms in Exponential Time. Outline Backtracking Local Search Randomization: Reducing to a Polynomial-Time Case Randomization: Permuting the Evaluation.
Complexity 19-1 Complexity Andrei Bulatov More Probabilistic Algorithms.
Computability and Complexity 24-1 Computability and Complexity Andrei Bulatov Approximation.
The effect of New Links on Google Pagerank By Hui Xie Apr, 07.
The Game of Algebra or The Other Side of Arithmetic The Game of Algebra or The Other Side of Arithmetic © 2007 Herbert I. Gross by Herbert I. Gross & Richard.
Randomized Algorithms Morteza ZadiMoghaddam Amin Sayedi.
Entropy Rate of a Markov Chain
Chapter 1 Probability and Distributions Math 6203 Fall 2009 Instructor: Ayona Chatterjee.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Generalized Semi-Markov Processes (GSMP)
Chapter 8. Section 8. 1 Section Summary Introduction Modeling with Recurrence Relations Fibonacci Numbers The Tower of Hanoi Counting Problems Algorithms.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
Order Statistics The ith order statistic in a set of n elements is the ith smallest element The minimum is thus the 1st order statistic The maximum is.
Lecture 22 More NPC problems
Markov Decision Processes1 Definitions; Stationary policies; Value improvement algorithm, Policy improvement algorithm, and linear programming for discounted.
Random Variables. A random variable X is a real valued function defined on the sample space, X : S  R. The set { s  S : X ( s )  [ a, b ] is an event}.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
Markov Chains and Random Walks. Def: A stochastic process X={X(t),t ∈ T} is a collection of random variables. If T is a countable set, say T={0,1,2, …
Generalized Semi- Markov Processes (GSMP). Summary Some Definitions The Poisson Process Properties of the Poisson Process  Interarrival times  Memoryless.
LDK R Logics for Data and Knowledge Representation Propositional Logic: Reasoning First version by Alessandro Agostini and Fausto Giunchiglia Second version.
On the Relation between SAT and BDDs for Equivalence Checking Sherief Reda Rolf Drechsler Alex Orailoglu Computer Science & Engineering Dept. University.
Random walks on undirected graphs and a little bit about Markov Chains Guy.
Seminar on random walks on graphs Lecture No. 2 Mille Gandelsman,
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
Presented by Dajiang Zhu 11/1/2011.  Introduction of Markov chains Definition One example  Two problems as examples 2-SAT Algorithm (simply introduce.
To be presented by Maral Hudaybergenova IENG 513 FALL 2015.
Copyright © Cengage Learning. All rights reserved. Sequences and Series.
Complexity 24-1 Complexity Andrei Bulatov Interactive Proofs.
Chapter 6 Large Random Samples Weiqi Luo ( 骆伟祺 ) School of Data & Computer Science Sun Yat-Sen University :
1 Distributed Vertex Coloring. 2 Vertex Coloring: each vertex is assigned a color.
Foundations of Discrete Mathematics Chapter 1 By Dr. Dalia M. Gil, Ph.D.
Theory of Computational Complexity Probability and Computing Lee Minseon Iwama and Ito lab M1 1.
Theory of Computational Complexity Probability and Computing Ryosuke Sasanuma Iwama and Ito lab M1.
Theory of Computational Complexity M1 Takao Inoshita Iwama & Ito Lab Graduate School of Informatics, Kyoto University.
From DeGroot & Schervish. Example Occupied Telephone Lines Suppose that a certain business office has five telephone lines and that any number of these.
CHAPTER SIX T HE P ROBABILISTIC M ETHOD M1 Zhang Cong 2011/Nov/28.
Krishnendu ChatterjeeFormal Methods Class1 MARKOV CHAINS.
Theory of Computational Complexity Probability and Computing Chapter Hikaru Inada Iwama and Ito lab M1.
Copyright © Cengage Learning. All rights reserved.
Markov Chains and Random Walks
Random walks on undirected graphs and a little bit about Markov Chains
Haim Kaplan and Uri Zwick
NP-Completeness Proofs
Randomized Algorithms Markov Chains and Random Walks
Foundations of Discrete Mathematics
Presentation transcript:

Random Walks and Markov Chains Nimantha Thushan Baranasuriya Girisha Durrel De Silva Rahul Singhal Karthik Yadati Ziling Zhou

Outline Random Walks Markov Chains Applications 2SAT 3SAT Card Shuffling

Random Walks

“A typical random walk involves some value that randomly wavers up and down over time”

Commonly Analyzed Probability that the wavering value reaches some end-value The time it takes for that to happen

Uses

The Drunkard’s Problem Will he go home or end up in the river?

Problem Setup 0 u w Alex

Analysis - Probability R u = Pr(Alex goes home | he started at position u) R w = 1 R 0 = 0 0 u w Alex

Analysis - Probability R u = Pr(Alex goes home | he started at position u) 0 u w Alex u-1 u+1

Analysis - Probability R u = Pr(Alex goes home | he started at position u) R u = 0.5 R u R u+1 0 u w Alex u-1 u+1

Analysis - Probability R u = 0.5 R u R u+1 R w = 1 R o = 0 R u = u / w

Analysis - Probability Pr(Alex goes home | he started at position u) = u/w Pr(Alex falls in the river| he started at position u) = (w –u)/w 0 u w Alex

Analysis - Time D u = Expected number of steps to reach any destination, starting at position u D 0 = 0 D w = 0 0 u w Alex

Analysis - Time 0 u w Alex D u = Expected number of steps to reach any destination, starting at position u D u = D u D u+1

Analysis - Time D u = D u D u+1 D 0 = 0 D w = 0 D u = u(w – u)

Markov Chains

Stochastic Process (Random Process) Definition: A collection of random variables often used to represent the evolution of some random value or system over time Examples The drunkard’s problem The gambling problem

Stochastic Process A stochastic process X For all t if X t assumes values from a countably infinite set, then we say that X is a discrete space process If X t assumes values from a finite set, then the process is finite If T is countably infinite set, we say that X is a discrete time process Today we will concentrate only on discrete time, discrete space stochastic processes with the Markov property

Markov Chains A time series stochastic (random) process Undergoes transitions from one state to another between a finite or countable number of states It is a random process with the Markov property Markov property: usually called as the memorylessness

Markov Chains Markov Property (Definition) A discrete time stochastic process X 0,X 1,X 2 …… in which the value of X t depends on the value of X t-1 but not on the sequence of states that led the system to that value

Markov Chains A discrete time stochastic process is a Markov chain if Where: States of the process State space Transition prob. from state

Representation: Directed Weighted Graph

Representation: Transition Matrix

Markov Chains: Important Results Let denote the probability that the process is at state i at time t Let be the vector giving the distribution of the chain at time i

Markov Chains: Important Results For any m >=0, we define the m -step transition probability as the probability that the chain moves from state i to state j in exactly m steps Conditioning on the first transition from i, we have

Markov Chains: Important Results Let P (m) be the matrix whose entries are the m -step transitional probabilities Induction on m Thus for any t >=0 and m >=1,

Example (1) What is the probability of going from state 0 to state 3 in exactly three steps ?

Example (1) Using the tree diagram we could see there are four possible ways! 0 – 1 – 0 – 3 | Pr = 3/32 0 – 1 – 3 – 3 | Pr = 1/96 0 – 3 – 1 – 3 | Pr = 1/16 0 – 3 – 3 – 3 | Pr = 3/64 All above events are mutually exclusive, therefore the total probability is Pr = 3/32 + 1/96 + 1/16 + 3/64 = 41/192

Example (1) Using the results computed before, we could simply calculate P 3

Example (2) What is the probability of ending in state 3 after three steps if we begin in a state uniformly chosen at random?

Example (2) This could be simply calculated by using P 3 The final answer is 43/288

Why do we need Markov Chains? We will be introducing three randomized algorithms 2 SAT, 3 SAT & Card Shuffling Use of Markov Chains model the problem Helpful in analysis of the problem

Application 1 – 2SAT

Example: a 2CNF formula (  x  y)  (  y  z)  (x  z)  (z  y) Literals A 2-CNF formula C 1  C 2  …  C a C i = l 1  l 2 Clauses AND OR 2SAT

(x 1   x 2 )  (x 2  x 3 )  (  x 1   x 3 ) x 1 = T x 2 = T x 3 = F x 1 = F x 2 = F x 3 = T Formula Satisfiability Another Example: a 2CNF formula

Given a Boolean formula S, with each clause consisting of exactly 2 literals, Our task is to determine if S is satisfiable 2SAT Problem

Algorithm: Solving 2SAT 1. Start with an arbitrary assignment 2. Repeat N times or until formula is satisfiable (a) Choose a clause that is currently not satisfied (b) Choose uniformly at random one of the literals in the clause and switch its value 3. If valid assignment found, return it 4. Else, conclude that S is not satisfiable

Start with an arbitrary assignment S = (x 1   x 2 )  (x 2  x 3 )  (  x 1   x 3 ) x 1 = F, x 2 = T, x 3 = F Choose a clause currently not satisfied Choose uniformly at random one of the literals in the clause and switch its value Choose C 1 = (x 1   x 2 ) check/loop Say x 1 = F now becomes x 1 = T Algorithm Tour

OR Only when the formula is satisfiable, but the algorithm fails to find a satisfying assignment N is not sufficient Goal: find N When will the Algorithm Fail?

Let X t = the number of variables that are assigned the same value in A* and A t S = (x 1   x 2 )  (x 2  x 3 )  (  x 1   x 3 ) n = 3 Suppose that the formula S with n variables is satisfiable That means, a particular assignment to the all variables in S can make S true x 1 = T, x 2 = T, x 3 = F A* Let A t = the assignment of variables after the t th iteration of Step 2 x 1 = F, x 2 = T, x 3 = F A 4 after 4 iterations X 4 = # variables that are assigned the same value in A* and A 4 = 2

When does the Algorithm Terminate? So, when X t = 3, the algorithm terminates with a satisfying assignment How does X t change over time? How long does it takes for X t to reach 3?

First, when X t = 0, any change in the current assignment A t must increase the # of matching assignment with A* by 1. S = (x 1   x 2 )  (x 2  x 3 )  (  x 1   x 3 ) x 1 = T, x 2 = T, x 3 = F A* x 1 = F, x 2 = F, x 3 = T X t = 0 in A t So, Pr(X t+1 = 1 | X t = 0) = 1 Analysis when X t = 0

1 ≤ j ≤ n-1 In our case, n = 3, 1 ≤ j ≤ 2, Say j=1, X t = 1 Choose a clause that is false with the current assignment A t Change the assignment of one of its variables Analysis when X t = j

What can be the value of X t+1 ? It can either be j-1 or j+1 In our case, 1 or 3 Which is more likely to be X t+1 ? Ans: j+1 Confusing? Analysis when X t = j

S = (x 1  x 2 )  (x 2  x 3 )  (  x 1   x 3 ) x 1 = T, x 2 = T, x 3 = F A* x 1 = F, x 2 = F, x 3 = F X t = 1 in A t Pick one false clause S = F  F  T

If we change one variable randomly, at least 1/2 of the time A t+1 will match more with A* (x 1  x 2 ) x 1 = T, x 2 = T A* x 1 = F, x 2 = T AtAt False x 1 = F, x 2 = F Pr(# variables in A t matching with A *) = 0.5 Pr(# variables in A t matching with A *) = 1

So, for j, with 1 ≤ j ≤ n-1 we have Pr(X t+1 = j+1 | X t = j) ≥ 1/2 Pr(X t+1 = j-1 | X t = j) ≤ 1/2 X 0, X 1, X 2 … are stochastic processes Random Process Yes Markov Chain No Confusing?

Pr(X t+1 = j+1 | X t = j) is not a constant This value depends on which j variables are matching with A*, which in fact depends on the history of how we obtain A t x 1 = T, x 2 = T, x 3 = F A* x 1 = F, x 2 = F, x 3 = F X t = 1 in A t x 1 = F, x 2 = T, x 3 = T Pr(X t+1 = 2 | X t = 1) = 0.5 Pr(X t+1 = 2 | X t = 1) = 1

To simplify the analysis, we invent a true Markov chain Y 0, Y 1, Y 2, …as follows: Y 0 = X 0 Pr(Y t+1 = 1 | Y t = 0) = 1 Pr(Y t+1 = j+1 | Y t = j) = 1/2 Pr(Y t+1 = j-1 | Y t = j) = 1/2 When compared with the stochastic process X 0, X 1, X 2, … it takes more time for Y t to increase to n (why??) Creating a True Markov Chain

Analysis - Time D u = Expected number of steps to reach any destination, starting from position u D u = D u D u+1 D v = D v-1 + D v+1 0 u w Alex

Thus, the expected time to reach n from any point is larger for Markov chain Y than for the stochastic process X So, we have E[ time for X to reach n starting at X 0 ] ≤ E[ time for Y to reach n starting at Y 0 ] Question: Can we upper bound the term E[time for Y to reach n starting at Y 0 ] ? Creating a True Markov Chain

Analysis Let us take a look of how the Markov chain Y looks like in the graph representation Recall that vertices represents the state space, which are the values that any Y t can take

Analysis Combining with the previous argument : E[ time for X to reach n starting at X 0 ] ≤ E[time for Y to reach n starting at Y 0 ] ≤ n 2, which gives the following lemma: Lemma : Assume that S has a satisfying assignment. Then, if the algorithm is allowed to run until it finds a satisfying assignment, the expected number of iterations is at most n 2 Hence, N = kn 2, where k is a constant

Let h j = E[time to reach n starting at state j] Clearly, h n = 0 and h 0 = h Also, for other values of j, we have h j = ½(h j-1 + 1) + ½(h j+1 + 1) By induction, we can show that for all j, h j = n 2 –j 2 ≤ n 2

Analysis If N = 2bn 2 ( k = 2b ), where b is constant the algorithm runs for 2bn 2 iterations, we can show the following: Theorem: The 2SAT algorithm answers correctly if the formula is unsatisfiable. Otherwise, with probability ≥ 1 –1/2 b, it returns a satisfying assignment

Break down the 2bn 2 iterations into b segments of 2n 2 Assume that no satisfying assignment was found in the first i - 1 segments What is the conditional probability that the algorithm did not find a satisfying assignment in the i th segment? Z is # of steps from the start of segment i until the algorithm finds a satisfying assignment Proof

The expected time to find a satisfying assignment, regardless of its starting position, is bounded by n 2 Apply Markov inequality Pr(Z ≥ 2n 2 ) ≤ n 2 /2n 2 = 1/2 Pr(Z ≥ 2n 2 ) ≤ 1/2 for failure of one segment (1/2) b for failure of b segments 1 –1/2 b for passing of b groups

Application 2 – 3SAT

Problem In a 3CNF formula, each clause contains exactly 3 literals. Here is an example of a 3CNF, where ¬ indicates negation: S = (x 1   x 2   x 3 )  (x 1  x 2  x 4 ) To solve this instance of the decision problem we must determine whether there is a truth value, we can assign to each of the variables ( x 1 through x 4 ) such that the entire expression is TRUE. An assignment satisfying the above formula: x 1 = T; x 2 = F; x 3 = F; x 4 = T

Use the same algorithm as 2SAT 1. Start with an arbitrary assignment 2. Repeat N times, stop if all clauses are satisfied a) Choose a clause that is currently not satisfied b) Choose uniformly at random one of the literals in the clause and switch its value 3. If valid assignment found, return it 4. Else, conclude that S is not satisfiable

Example S = (x 1   x 2   x 3 )  (x 1  x 2  x 4 ) An arbitrary assignment: x 1 = F; x 2 = T; x 3 = T; x 4 = F Choose an unsatisfied clause: (x 1   x 2   x 3 ) Choose one literal at random: x 1 and make x 1 = T Resulting assignment: x 1 = T; x 2 = T; x 3 = T; x 4 = F Check if S is satisfiable with this assignment If yes, return Else, repeat

Analysis S = (x 1   x 2   x 3 )  (x 1  x 2  x 4 ) Let us follow the same approach as 2SAT A* = An assignment which makes the formula TRUE A*: x 1 = T; x 2 = F; x 3 = F; x 4 = T A t = An assignment of variables after t th iteration A t : x 1 = F; x 2 = T; x 3 = F; x 4 = T X t = Number of variables that are assigned the same value in A* and A t X t = 1

Analysis Contd.. When X t = 0, any change takes the current assignment closer to A* Pr(X t+1 = 1 | X t = 0) = 1 When X t = j, with 1 ≤ j ≤ n-1, we choose a clause and change the value of a literal. What happens next? Value of X t+1 can become j+1 or j-1 Following the same reasoning as 2SAT, we have Pr(X t+1 = j+1 | X t = j) ≥ 1/3 Pr(X t+1 = j-1 | X t = j) ≤ 2/3; where 1 ≤ j ≤ n-1 This is not a Markov chain!!

Analysis Thus, we create a new Markov chain Y t to facilitate analysis Y 0 = X 0 Pr(Y t+1 = 1 | Y t = 0) = 1 Pr(Y t+1 = j+1 | Y t = j) = 1/3 Pr(Y t+1 = j-1 | Y t = j) = 2/3

Analysis Let h j = E[time to reach n starting at state j ] We have the following system of equations h n = 0 h j = 2/3(h j-1 + 1) + 1/3(h j+1 + 1) h 0 = h h j = 2 n j+2 - (n-j) On an average, it takes O(2 n ) – Not good!!

Observations Once the algorithm starts, it is more likely to move towards 0 than n. The longer we run the process, it is more likely that it will move to 0. Why? Pr(Y t+1 = j+1 | Y t = j) = 1/3 Pr(Y t+1 = j-1 | Y t = j) = 2/3 Modification: Restart the process with many randomly chosen initial assignments and run the process each time for a small number of steps

Modified algorithm 1. Repeat M times, stop if all clauses satisfied a) Choose an assignment uniformly at random b) Repeat 3n times, stop if all clauses satisfied i. Choose a clause that is not satisfied ii. Choose one of the variables in the clause uniformly at random and switch its assigned value 2. If valid assignment found, return it 3. Else, conclude that S is unsatisfiable

Analysis Let q = the probability that the process reaches A* in 3n steps when starting with a random assignment Let q j = the probability that the process reaches A* in 3n steps when starting with a random assignment that has j variables assigned differently with A* For example, A t : x 1 = F; x 2 = T; x 3 = F; x 4 = T A*: x 1 = T; x 2 = F; x 3 = F; x 4 = T q 2 is the probability that the process reaches A* in ≤ 3n steps starting with an assignment which disagrees with A* in 2 variables.

Bounding q j

Bounding q q ≥ (c/n 0.5 )(3/4) n

Bound for the algorithm If S is satisfiable, then with probability ≥ ( c / n 0.5 )(3/4) n we obtain a satisfying assignment Assuming a satisfying assignment exists The number of random assignments the process tries before finding a satisfying assignment is a geometric random variable with parameter q The expected number of assignments tried is 1/ q

Bound for the algorithm The expected number of steps until a solution is found is bounded by O(n 3/2 (4/3) n ) Less than O(2 n )

Satisfiability: Summary Boolean Satisfiability problem: Given a boolean formula S, find an assignment to the variables x 1, x 2, …, x n such that S(x 1, x 2, …, x n ) = TRUE or prove that no such assignment exists Two instances of the satisfiability problem 2SAT: The clauses in the boolean formula S contain exactly 2 literals. Expected number of iterations to reach a conclusion – O(n 2 ) 3SAT: The clauses in the boolean formula S contain exactly 3 literals. Expected number of iterations to reach a conclusion – O((1.3334) n )

Application 3 – Card Shuffling

Card Shuffling Problem We are given a deck of k cards We want to completely shuffle them Mathematically: we want to sample from the uniform distribution over the space of all k ! permutations of the deck Key questions : Q1: Using some kind of shuffle move, is it possible to completely shuffle one deck of cards? Q2: How many moves are sufficient to get a uniformly random deck of cards? Depends on how we shuffle the cards A deck of cards Shuffled Cards A number of shuffle moves

Card Shuffling – Shuffle Moves Shuffle Moves Top in at random Random transpositions Riffle shuffle We can model them using Markov chains Each state is a permutation of cards The transitions depend on the shuffle moves

Card Shuffling – Markov Chain model A 3-card example (top-in-at-random) C1 C2 C3 C2 C3 C1 C2 C1 C3 C1 C2 C3 C2 C1 C3 C2 1/3

Card Shuffling – Markov Chain model Answer Q1: Can top-in-at-random achieve uniform random distribution over the k! permutations of the cards? Markov Chain’s stationary distribution: Fundamental Theorem of Markov Chain: If a Markov Chain is irreducible, finite and aperiodic It has a unique stationary distribution After sufficient large number of transitions, it will reach the stationary distribution

Card Shuffling – Markov Chain model

Top in at Random – Mixing Time Answer Q2: How many shuffle steps are necessary to get the stationary distribution? Key Observation 1: when a card is shuffled, its position is uniformly random. Key Observation 2:Let card B be on the bottom position before shuffling. When shuffling, all cards below B are uniformly random in their position. Let T be the r.v. of the number of shuffling steps for B to reach the top. After T+1 steps, the deck is completely shuffled

Top in at Random – Mixing Time

Card Shuffling Problem

Proof

Thank You Any Questions ?

References Mathematics for Computer Science by Eric Lehman and Tom Leighton Probability and Computing - Randomized Algorithms and Probabilistic Analysis by Michael Mitzenmacher and Eli Upfal Randomized Algorithms by Rajeev Motwani and Prabhakar Raghavan