Friday 20 September 2019

Why songs repeat on your phone when played on shuffle?

When you have your favourite radio station playing songs that are not so favourite of yours the greatest thrill is to finally hear the intro of the one that you’ve been waiting for… for last three hours.

Well, those days are gone into the abyss of the past. We can have hundreds upon hundreds of our favourite songs right in our palm, literally. Our mobile phones have enormous capacities nowadays and it is easy to collect overwhelmingly large numbers of songs.

Many of these tunes are mildly amusing to us but we still keep them just because we can or we liked them initially, paid for them and now they’ve gotten old and we have moved on, yet we keep them for old time’s sake. Many a times, we just want to possess them but not really play them. But when you have over 500 tracks in your phone and you’re playing them on shuffle, somehow same songs keep repeating and the ones that you’re really waiting for never seem to play, just like old times when all you had was your trusty old radio.

I have suffered from the same first-world problem for a while now. I have recently bought and downloaded about half a dozen new tracks and dutifully included them in my 800 plus tracks long playlist. However, my phone seems to hate these tracks. They have yet to come on. I have played over 600 songs including all the repeats.

One afternoon, I had some time to kill and Microsoft Office handy. I decided to do some research as to why some songs play more often than others.

First of all, you must understand that the shuffle feature uses a randomization function included in every programming language that I have come across. It has different names in different programming languages but has the same purpose – to generate a random fraction between 0.000 and 0.999 inclusively. Once a random fraction has been generated any number can be returned by using simple arithmetic. This randomization can be used for electronic toss, generate lottery results or pick items from a list randomly. Our phones use the same randomization to randomly pick songs to play for us. However, turns out there is a caveat.

Randomization is not hundred percent random in a manner of speaking. Some numbers come up more often than others. Why? I don’t know. I did not dig that deep. What I did was run a hypothetical scenario with the help of randomization feature in Microsoft Excel and then analyzed it with Microsoft Access.

I created a list of integers, 1 to 850, each number representing a unique song in my phone. Then I asked Excel to randomly pick a number 850 times out of these 850 numbers. I repeated the process 5 times. In this hypothetical scenario, I have 850 songs. My phone played 4,250 songs – each song is counted each time it’s played, for example if Gangnam Style is played 5 times it’s counted as 5 songs. I wanted to see after 4,250 playbacks, going through 850 playbacks (total number of my songs) 5 times over, which songs were repeated and which ones were skipped altogether by the randomization system employed by the shuffle feature of music player application.
I gathered all the numbers and analyzed them. The result was surprising, if not shocking. In 4,250 hypothetical playbacks, 3 songs were never played and 29 songs were played 10 or more times. 161 songs were played 5 times. More than 96% of songs were repeated more than once.

37% of the songs were repeated more than 5 times when in 5 cycles of 850 playbacks, ideally no song should be repeated more than 5 times.

Interestingly, 30 songs were played only once and 44% songs were played less than 5 times.

This analysis reveals that using a simple randomization for shuffling songs in a playlist leaves much to be desired. Ideally, before the beginning of first song in any given playlist, the songs should be shuffled in a way that none repeat until all on them have been played at least once. It is not too difficult and might take a few milliseconds more than just randomly picking tracks from the list.

No comments: