# Life is random

Did you ever think the program running in your iPod was math-savvy? Maths surely couldn’t have infiltrated your loyal iPod. But the truth is always bitter! Ever thought about how the whole music shuffling thing works? It must have felt(if you chose to be blissfully ignorant) as if there was some divine entity out there which governed the next song in your playlist. Well, that divine entity is Mathematics.

The Math used to shuffle music is not too complicated and involves basic combinatorics. Say you had only three songs in your iPod and you chose to listen to them in the shuffled mode. What are the possible sequences of songs you may hear?

Assuming the three tracks to be A, B and C:

Six sequences of songs are possible. If you had five songs in your music library, how many sequences would be possible? It is clearly a basic combinatorics problem and the answer is  bigger than you probably think it is. Such a problem is more specifically known as a permutations problem since you are considering all possible sequences possible with the elements in a given set. Here the songs are the elements and the music library is the set. Let’s see how we can come upon the number of sequences possible with five music tracks.

The software would have five choices of songs to fill in the first box. Say it randomly picks track C.

Since it chose track C for the first box, it has only four songs left to choose from for the second box. Here, say it randomly chooses track E.

Now the software has only three songs left to choose from. Suppose it decides on track A.

Here the software settles on track D.

Finally, the software is left with only one choice, track B, to play as the last song. Thus the program has decided on the jumbled queue that it will follow. However, this was only one of many possibilities. If the first song had instead been track D, it would result in a new playlist. The total number of possible sequences would have become evident by now:

$\textbf{No. of sequences} = 5 \times 4 \times \times 3 \times 2 \times 1 = 120$

More generally, the formula for calculating the permutations possible in such situations is :

$\textbf{Permutations} = \prod \limits_{1}^{N} i = \text{N!}$.

So that’s the mathematical wizardry performed by your iPod(or any other music player) when you ask it to shuffle the music in the library. You may be wondering about the strange title to this article. “Life is random” was actually Apple’s slogan for convincing its customers of the utility of jumbling one’s music. It turns out that soon after shuffling was introduced, many Apple customers complained about the manner in which their music was being shuffled, claiming that they were often hearing similar music and alleging that the shuffling software was tampering with their music. But what was Apple’s fault in this, it had rightly deployed a program that operated on probability and combinatorics, allowing each song an equal chance to be played. To resolve these criticisms, guess what Apple did? It modified its software to be less randomized. In other words, Apple tricked its customers into believing that the shuffling software had become more random and fair, by making it more systematic and biased!