Joe Fedewa / How-To Geek
If you’ve ever used the shuffle button on Spotify, you’ve probably noticed it often doesn’t feel random at all. Turns out this is by design, and there’s actually a lot that goes into how shuffle works on Spotify.
You are very much not alone if this is a complaint you’ve had. The Spotify Support forums and Reddit are littered with people airing their grievances about the shuffle feature. It’s clearly not working how people expect it to work. Let’s take a look at why that is.
Random Doesn’t Feel Random
The core of this situation is our perception of what’s random versus how random works in the real world. The common complaint is Spotify’s shuffle mode doesn’t feel random, but true random is not what we actually want.
Flipping a quarter is a good example of this. If the coin is flipped 10 times, we expect to see a relatively even distribution of heads and tails. However, true random can just as easily result in 10 straight heads. Each time the coin is flipped, there’s a 50/50 chance it will be heads or tails. That chance doesn’t change depending on the previous coin flip.
Two equally random orders. Spotify
The same thing applies to songs in a playlist. True random could end up playing the same artist a bunch of times in a row—there’s an equal chance for each song to play every time. Up until 2014, this was how the shuffle feature worked, but people complained that it wasn’t random enough. So, Spotify changed it up.
How Spotify Shuffle Works
When you press the “Next” button, Spotify does not randomly select the next song right then and there. The next song was already decided at the moment you turned on shuffle mode.
The name “shuffle” is actually a very accurate description of how it works. Think of it like shuffling a deck of playing cards. When you tap the shuffle button on a playlist, all the songs are shuffled into a new order. This happens every single time you click the shuffle button.
You can see this if you check the queue. I made a playlist of 10 songs—half of which are from the same artist—and put it on shuffle five times. Spotify generated a new order of songs each time. Even in this small sample size, you can clearly see some of the issues people complain about.
The same song was at the top of the list the first two times I shuffled—that’s more “random doesn’t feel random.” More importantly, the artist that appears in the playlist five times is never evenly distributed. In fact, in two of the shuffles, four out of the five songs were grouped together.
That’s how Spotify shuffle works on a basic level, but again, this is not random. Spotify stopped using true random in 2014. Now there’s an algorithm that decides the shuffle.
Enter the Algorithm
Thankfully, an engineer at Spotify outlined exactly how the algorithm works on Spotify’s Engineering blog in 2014. The algorithm has almost certainly been tweaked since then, but it’s surprisingly simple.
First, the algorithm spreads out songs from the same artist. However, it intentionally doesn’t always do this perfectly—as seen above—to maintain a sense of randomness. Generally, they’ll appear every 20-30% of the length of the playlist.
Each color is an artist. Spotify.
The algorithm also shuffles the songs by the same artist among each other. This is to prevent songs from the same albums from playing too closely together. Artists that only appear once in the playlist have a “random offset” to prevent them from always being at the top of the list.
That’s it! The algorithm itself is quite simple. Maintaining a feeling of randomness is what really complicates things. If shuffle always perfectly arranged the artists in equal distance from each other, it would feel like a repetitive pattern. Shuffle has to strike a balance between true randomness and manufactured randomness.
Random Is Hard
There are more advanced music shuffling algorithms out there. The problem is adding complexity can make algorithms slower. Spotify‘s algorithm is simple, but that allows it to shuffle almost instantly.
The human brain makes the concept of “random” hard to execute. The algorithm is more about creating the illusion of randomness than true randomness because that is what our brains want. The system is never going to be perfect, but you can always hit the shuffle button one more time.
If you’re still curious about this topic, check out this excellent video by Gabi Belle on YouTube.