CS70 Cheatsheet
CS70 Cheatsheet
1
CS 70 C HEATSHEET A LEC L I
2
CS 70 C HEATSHEET A LEC L I
Note 24 (Markov Chains) Note: Do not blindly copy down the content on this
• Markov chain = sequence of states cheatsheet (this is one of the reasons why I typed this in
• X n = state at time step n LATEX, as you cannot just print it out and use it). My goal
• X = state space (finite) in making my cheatsheet publicly available is to ease
• πn = distribution of states at time step n your studying and to provide a general guideline for the
• Markov property (memoryless): P(X n+1 = i | X n , X n−1 , . . . , X 0 ) = kinds of things that you could put on your cheatsheet.
P(X n+1 = i | X n ) The most helpful part of a cheatsheet is the process of
• Transition matrix (P): transition probabilities, from row to column making it—you synthesize and review the course mate-
• π n = π 0 Pn rial yourself and pick out what you think is important.
• Invariant distribution: π = πP; solve balance equations in addition I guarantee that there are concepts in the notes/lec-
to π(i ) = 1
P
tures/discussions not on my cheatsheet that you should
• Irreducible Markov chain: any state can be reached from any other know, and I also guarantee that there are things on my
• All irreducible Markov chains have a unique invariant distribution: cheatsheet that may be of no use to you. This is a collec-
1 n−1 tion of items that helped me when I took the class, and
π(i ) = lim
X
1{X m = i }.
n→∞ n
m=0 only you know what benefits you the most. My advice is
That is, average time spent at state i = π(i ) to make your own cheatsheet first, without referencing
• Periodicity: let d (i ) = gcd{n > 0 : P(X n = i | X 0 = i ) > 0} mine, and then going over my cheatsheet afterward to
– If d (i ) > 1, periodic with period d add things that you may have missed.
– If d (i ) = 1, aperiodic Good luck on your exams!
– If irreducible, all states have the same d (i )
• Aperiodic irreducible Markov chains will always converge to the
invariant distribution
• Hitting time: # of steps before first reaching state i
– Let β( j ) denote this value, starting at state j ; set up system of
equations and solve
• P(A before B ): similarly, let α( j ) denote this probability, starting at
state j ; set up system of equations and solve (use TPR)
• Similar problems: let f (i ) denote # of steps or probability, starting
at state i ; set up equations and solve
• 2-state Markov chain:
a
1−a 1 2 1−b
b
· ¸
1−a a h
b a
i
P= and π = a+b a+b
b 1−b
Other
• In CS70, naturals and whole numbers both include 0
n
• Sum of finite geometric series: 1−r 1−r a where r is ratio, a is first
term, n is number of terms
• Memoryless property independence: if X , Y both memoryless
(i.e. geometric or exponential), then min(X , Y ) and max(X , Y ) −
min(X , Y ) are independent
n
P
• If S n = X i , then (useful for variance of indicators)
i =1
h i X n h i X h i Xn h i X h i
2
E Sn = E X i2 + E Xi X j = E X i2 + 2 E Xi X j
i =1 i ̸= j i =1 i<j
• Coupon Collector Problem:
– n distinct items, each with equal probability; X i = # of tries be-
fore i th new item, given i − 1 already
P
– S n = X i = total tries before getting all items
– We have X i ∼ Geom( n−in+1 ) because i − 1 old items, so n − i + 1
new items
– Hence,
n £ ¤ X n n n 1
E[S n ] = E Xi =
X X
=n ≈ n(ln n + 0.5772)
i =1 i =1 n − i + 1 i =1 i
3
CS 70
Table 1: Common Discrete Distributions
Distribution Parameters PMF (P(X = k)) CMF (P(X ≤ k)) Expectation (E[X ]) Variance (Var(X )) Support
1 k −a +1 a +b (b − a + 1)2 − 1
Uniform Uniform(a, b) X ∈ [a, b]
b −a +1 b −a +1 2 12
(
p k =1
Bernoulli Bernoulli(p) — p p(1 − p) X ∈ {0, 1}
1−p k = 0
à !
n k
Binomial Bin(n, p) p (1 − p)n−k — np np(1 − p) X ∈ {0, 1, 2, . . .}
k
1 1−p
Geometric Geom(p) p(1 − p)k−1 1 − (1 − p)k X ∈ {1, 2, 3, . . .}
p p2
λk e −λ
Poisson Pois(λ) — λ λ X ∈ {0, 1, 2, . . .}
k!
¡K ¢¡N −K ¢
k n−k K K (N − K )(N − n)
Hypergeometric Hypergeometric(N , K , n) — n n X ∈ {0, 1, 2, . . .}
N 2 (N − 1)
¡N ¢
N
n
C HEATSHEET
Distribution Parameters PDF ( f X (x)) CDF (F X (x) = P(X ≤ x)) Expectation (E[X ]) Variance (Var(X )) Support
4
1 x −a a +b (b − a)2
Uniform Uniform(a, b) X ∈ [a, b]
b−a b−a 2 12
1 1
Exponential Exp(λ) λe −λx 1 − e −λx X ∈ [0, ∞)
λ λ2
à !
1 (x − µ)2
Normal/Gaussian N (µ, σ2 ) exp − Φ(x) µ σ2 X ∈R
2σ2
p
2πσ2
A LEC L I