# Conditional Probability, Markov Chain Matrices

In Freedonia, every day is either cloudy or sunny (not both). If it's sunny on any given day, then the probability that the next day will be sunny is $\frac 34$. If it's cloudy on any given day, then the probability that the next day will be cloudy is $\frac 23$.

a. In the long run, what fraction of days are sunny?

b. Given that a consecutive Saturday and Sunday had the same weather in Freedonia, what is the probability that that weather was sunny?

I tried using weighted coins, but that didn't work. Can I get two answers, one for each problem, solution not necessary, as I need to figure out which of my methods leads to the correct answer. Thanks.

I found a congruent problem, but it didn't have answers I could comprehend.

Consider a 'cycle': Start with a sunny day; probability of changing to a rainy day is 1/4. so on average a run of sunny days will be four days long. Then (by similar logic) there will be a run of rainy days averaging four days in length. Average cycle length is 7 days of which 4 are sunny. Answer to (a) is 4/7.

Addendum: Here is a simulation of 100,000 steps of the chain using R software, where state 0 = Sun and state 1 = Rain. (Note that @GrahamKemp's excellent Answer, posted while I was working on this, uses 1 = Sun and 0 = Rain.)

For your part (a), We already know that the steady-state distribution has sum 4/7 of the time; this is consistent with simulation results. For your part (b), the required conditional probability is 3/5, again consistent with simulation results.

 m = 100000; n = 1:m;  alpha = 1/4;  beta = 1/3
x = numeric(m); x = 0
for (i in 2:m)  {
if (x[i-1]==0) x[i] = rbinom(1, 1, alpha)
else x[i] = rbinom(1, 1, 1 - beta)  }
mean(x==0); 4/7
## 0.56847
## 0.5714286
x1 = x[1:(m-1)];  x2 = x[2:m]
mean(x1[x1==x2]==0);  3/5
## 0.5958692
## 0.6


A sketch of my rationale for (b) is $P(\text{SS}) = (4/7)(3/4) = 3/7,\;$ $P(\text{RR}) = 2/7.\;$ So the answer is $\frac{3/7}{3/7 + 2/7}.$

You asked for answers to check against the ones you already obtained. I have tried to give them to you in a way that may show you how to think about such simple Markov chains from points of view that may not be in your textbook.

(a) If $p$ is the long-term probability (aka equilibrium point) that it is sunny, then the probability that it is sunny on a following day is also $p$, so: $\Box p + \Box (1-p) = p$

Likewise the probability that it is not sunny on the subsequent day is: $\Box p + \Box (1-p) = (1-p)$.

Fill in the boxes from the given information and solve the simultaneous equation

(b) Use this value as the prior probability that the weather is sunny on Saturday, and construct a Bayesian case for the posterior probability for the given condition.

Let $T$ be the indicator event that it is sunny on Saturday, and $N$ the indicator event that it is sunny on Sunday.   We have from the long-term probability: $\mathsf P(T=1)=p, \mathsf P(T=0)=(1-p)$ and also from the given information: $\mathsf P(N=1\mid T=1)=3/4, \mathsf P(N=0\mid T=0)=2/3$.

Find $\mathsf P(T=1 \mid N=T)$ using conditional probability rules.

• So in a) the first equation will be .9p+.1(1-p)=p and the second equation: .2p+.8(1-p)=1-p ? Am I right? – Aaron Martinez Apr 30 '17 at 0:24