# Expected values with many if statement

Hi I was working on this question for my exam review:

A group of $n \geq 3$ people is sitting at a round table, so that each person has two neighbors, one clockwise neighbor and one counterclockwise neighbor. Each person flips a fair and independent coin. A person starts singing if and only if (i) his coin comes up heads, (ii) the coin of his clockwise neighbor comes up tails, and (iii) the coin of his counter clockwise neighbor comes up tails. Let X be the random variable whose value is the number of people that are singing. What is the expected value E(X) of X?

The textbook answers page says n/8 but I have no idea how it ended up with that answer even though understand the basic concept of expected value any help?

Let's $Z_i$ denotes the outcome of coin toss for person $i$ and $Y_i$ is a Bernoulli random variable denoting whether he/she sings or not. We have: $$X=Y_1+\dots+Y_n$$ which means that: $$\mathbb E(X)=\mathbb E(Y_1)+\dots+\mathbb E(Y_n).$$ But for each person we have (with proper changes for $i=1,n$): $$\mathbb E(Y_i)=\Pr(Y_i=1)=\Pr(Z_i=H,Z_{i-1}=T,Z_{i+1}=T)=\frac 12\times\frac 12\times \frac 12=\frac 18$$ Therefore: $$\mathbb E(X)=\mathbb E(Y_1)+\dots+\mathbb E(Y_n)=\frac n8.$$