Do iPods really shuffle?

When Apple first launched the iPod Shuffle, they used the slogan “Life is random” to promote the benefits of jumbling up your playlist to make every new track a surprise. But just how random is the “shuffle” option on iPods and other MP3 players? Some listeners accuse their iPods of playing the same songs over and over, or wonder how it’s possible to “randomly” hear two songs by the same artist in a row. These strange patterns aren’t the result of a programming error or a defective player though – it’s all down to the maths of probability.

Pick a track, any track

Shuffling a playlist tells your iPod to literally shuffle up the songs like a deck of cards. The only difference is the numbers involved. A normal deck contains 52 cards, which can be arranged in nearly 1068 ways – that’s a 1 followed by 68 zeros. An average music collection however might contain a thousand tracks, and they can be arranged in about 102568 ways, or 1 followed by 68 zeros, followed by another 2500 zeros!

Shuffling cardsThat’s a lot of shuffling, but we can make the maths simpler with a smaller example. Suppose we’ve got a playlist of just five songs. To work out the number of ways of combining n objects, you have to multiply all the numbers from 1 to n. For five songs, that works out as 120 possible playlists. But how many of them have two tracks by the same artist in a row?

Obviously, it depends which 5 tracks we start with. If they’re all by different bands, then no playlists will have repeating tracks, while if they’re all from the same album then every track will be a repeated artist! Let’s say we have just two songs by the same artist (call them A and B) and the other three are all by different artists (C, D, and E). Out of the 120 possible playlists, how many will have A follow by B, or B followed by A? In other words, how often can we expect to hear a repeat?

Counting music

Think of all the possible positions of A and B in a playlist. They could be right at the start, or right at the end, or somewhere in the middle. If we use x to stand for the other three tracks, then the possible positions are:

ABxxx

xABxx

xxABx

xxxAB

There are six possible ways for the first position to happen: ABCDE, ABCED, ABDCE, ABDEC, ABECD, and ABEDC. That’s because there are six possible ways to arrange the other three tracks – remember, you just multiply the numbers from 1 to n, which in this case are 1 × 2 × 3 = 6. For the same reason, it turns out that there are six possibilities for all the other positions as well, giving us 6 × 4 = 24.

What about playlists where B comes before A? We’re interested in how many times we hear A and B in a row, but it doesn’t matter whether A or B comes first. That means we can switch their places and run through the possible positions again:

BAxxx

xBAxx

xxBAx

xxxBA

Although the letters have changed, the maths is still the same. Just like before, there are six possible ways for each position to happen, giving us another 24 possible playlists. Adding the AB playlists to the BA playlists, we find there are 48 out of 120 playlists that give us two songs by the same artist in a row. That’s 40%, which means there’s a pretty good chance of getting a repeated artist when you put your songs on shuffle.

Not so random

Do iPods really shuffle? A real-life iPod will have loads more songs than just five of course, but the mathematical rules governing randomness are exactly the same. Listen to your music for long enough, and you’ll start hearing patterns that don’t seem random at all – even though they actually are.

In fact, so many people complained about their iPods not being random enough that Apple eventually modified its software. Instead of shuffling tracks like they were playing cards, the iPod now examines the track you’re listening to and picks one that isn’t too similar, based on the track information. As Apple said, “We’re making it less random to make it feel more random.” So if you suspect your MP3 player of playing tricks on you, relax – it’s just probability at work!