A conditional probability problem where the next day depends on the last 3 days

Note: edited since the question was clarified.

First, we cannot ever have two or more consecutive sunny days. If we do, then the next cloudy day (which may not be for some time, but will certainly be preceded by two sunny days) must be followed by two sunny days (since SSC->S, SCS->S), and the same for the next cloudy day after that, and so on. In particular, every future cloudy day is followed by a sunny day, contradicting the assumption that $50\%$ of cloudy days are followed by sunny ones.

Second, we cannot ever have two sunny days separated by a single cloudy day, since then the next day will be sunny, contradicting the previous point.

Now we know that in between every two sunny days there are at least two cloudy days. These cloudy days must include one which is followed by a sunny day, and at least one which is followed by another cloudy day. Since these two things are equally common, we must have exactly two cloudy days between every two sunny days.

Thus the unique sequence satisfying these properties is ...SCCSCCSCC... in which exactly $2/3$ are cloudy.


Here is an attempt to solve the problem:

Let's define the problem by a Markov chain, where a state of the chain is defined by the state of last (most recent) 3 consecutive days observed at any point in time (e.g., the state represented by CCC can transition to any of the two states, namely, itself, i.e., CCC and CCS). The state transition diagram will look like the following then

enter image description here

Notice that we don't have all the probabilities given to us (those are circled in the above figure), but some of them can be inferred and some of them can't be. For example, given, P(SCC|CCC)=1/2, so, consequently, P(CCS|CCC)=1-1/2=1/2. But we don't know either of P(SSS|SSS) and P(SSC|SSS), these are marked by x in the above figure.

For the sake of completeness (and simplicity), let's assume uniform probabilities for the unknown ones, e.g., let P(SSS|SSS) = P(SSC|SSS) = 1/2.

Then the Markov transition matrix becomes the one as shown below:

enter image description here

Now, the Markov chain being connected and aperiodic, by Perron-Frobenius theorem, it converges to stationary distribution in the long run.

Let's compute the stationary distribution, using the following R code with the Markov transition matrix $T$:

S <- T
for (i in 1:100)
  S <- S %*% T

enter image description here

Which shows that in the long run the Markov chain will be in the states CSS, SSC, SCS and SSS with probabilities 0.2, 0.2, 0.2 and 0.4, respectively. But the proportion of sunny days in these states are 2/3, 2/3, 2/3 and 1, respectively.

Hence, the expected number of sunny days will be = 0.22/3 + 0.22/3 + 0.2*2/3 + 0.4 = 0.8