Suppose you have a playlist consisting of four songs that you play in a smart shuffle mode. In this mode, after the current song is played, the next song is chosen randomly from the other three tracks. This ensures you never hear the same song twice in a row. Let X be the number of songs you listen to until you've heard all the four different songs.

I am trying to calculate the variance of X (Var(x)). But I am stuck on how to approach it in this case. I have calculated the expected value to be E(x) = 25/3 but I was looking at some class notes and think this problem is more than just doing the regular formula for variance using expectation. I am stuck trying to figure out how to approach this exactly.

Any help is appreciated, thank you.


This question has many parts which I've worked out.

1.How many sequences of 4 songs are there where no song plays twice in a row? If we label the songs {A, B, C, D}, then examples are ABCD and ABAB but not ABBA.

Answer: 108

2.What's the value of P(X = 4)?

Answer: 6/27

  1. What's the value of P(X = 5)

Answer: 5/7

  1. What is the value of E(X)?

Answer: 25/3

  1. Var(X) = ?

This is where I am stuck, and need clarification/ help.

  • $\begingroup$ What do you mean? I added more for clarification. This does map to real numbers. $\endgroup$ – userunknown Apr 15 '14 at 14:21
  • $\begingroup$ Uh, sorry, I thought $X$ was the song that's played, not the number of songs. Sorry. To compute $Var(X)$, you can use that $Var(X) = E(X^2) - (E(X))^2$. Since you already found $E(X)$, I guess you'll find $E(X^2)$ too. $\endgroup$ – fgp Apr 15 '14 at 14:27
  • $\begingroup$ I do not think I can use that formula if you take a look at these slides: people.cs.umass.edu/~mcgregor/240S13/lec15.pdf $\endgroup$ – userunknown Apr 15 '14 at 14:35
  • $\begingroup$ You can always use this formula! Sometimes there might be an easier way, particularly if computing $E(X^2)$ is hard, but the formula is never wrong. $\endgroup$ – fgp Apr 15 '14 at 14:37

First off, your probabilities are wrong.



$P(X=2)= 3/4 \times 1/3=1/4$

$P(X=3)= 3/4 \times 2/3 \times 1/3= 1/4 \times (2/3)$

$P(X=4) = 3/4 \times 2/3 \times 2/3 \times 1/3 = 1/4 \times (2/3)^2=1/9 \neq 6/27$.

To get the expectation you just compute

$$EX = \sum_{j=1}^\infty P(X=j) j.$$

To get the variance you compute

$$EX^2 = \sum_{j=1}^\infty P(X=j) j^2,$$

and then


as suggested in one of the comments.

Given that this is homework I'll let you fill in the details.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.