Spotify's Random FAIL
Tags: javascript, programming, ux, math
Published: 2020-07-10 14:13:56

As a programmer, I don't consider endless streaming music to be a luxury.  Good tune-age is, quite literally, a core requirement of my workspace.  To satisfy that need, I'm a Spotify Premium member.

For the most part, it's an epic service.  If I divided my monthly bill by the hours of music I receive, it would easily be one of best values I've ever purchased.  But that doesn't mean that Spotify is without faults.  And at certain points in the past, those faults have driven me absolutely **INSANE**.

[NOTE: This is the second half of my treatise on randomness - and how it can ruin your users' experience.  In the first article, I outlined some of the cognitive biases that can undermine "random" features in applications.  You can read it here: https://dev.to/bytebodger/random-can-break-your-app-58bo]
<br/><br/>

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/i9tryzgfrlr3m7a7dltq.jpg)
## Spotify Don't Know Shuffle
I have playlists.  Most hardcore Spotify users do.  My blues playlist has 436 tracks.  My drum-n-bass playlist has 613 tracks.  Most of my heavily-curated playlists have somewhere between 400 and 700 tracks.  

I often switch between my playlists depending upon what's going on in my day and where I need my "headspace" to be.  When I'm in frenetic code-euphoria mode, I'm cranking out my drum-n-bass list.  When I'm in a more contemplative place, I might be listening to traditional jazz.  So over the course of a single day, I might spend an hour-or-two listening to as many as 10 different playlists.

Here's the problem:  

When I switch to a new playlist, I want to come into that playlist as though I've just switched the radio dial to a targeted genre station.  That station doesn't know "where I left off".  That station doesn't know what I might have heard yesterday.  The station just keeps cranking along, oblivious to whether I'm listening or not.

The station has an expansive list of tracks they'll play.  And they play those tracks, more-or-less randomly, over the course of several days.  And I want my Spotify experience to mirror this.

But Spotify stubbornly, angrily, obstinately, pig-headedly _refuses_ to let me have this experience.  This refusal comes in the form of their utter disregard for their so-called "shuffle" function.
<br/><br/>

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ah97mvnox9uenmy8eh94.jpg)
## A Shuffling Fraud
If you've ever used Spotify yourself, you might be thinking:
<br/>

> But Spotify _has_ a shuffle feature.  It's a button that looks like two crossing arrows.

<br/>And of course, you'd be right.  Spotify does indeed have such a feature.  But the feature has nothing to do with a "shuffle".  It's a _lie_.  Spotify does "shuffle" the same way that Republicans do "civil rights".  It's a button that does... something.  But whatever it's doing, it has no relation to the label.

You see, in a perfect world, "shuffling" implies a true randomization of the data set.  As I covered in the previous article, "random" doesn't mean that it will satisfy what every layperson views as "random".  "Random" means _truly damn random_.  

In other words, when you truly _randomize_ a data set, it will have no bearing on any previous results.  "Random" can, in fact, contain "trends" (although they are trends that will evaporate once you try to track them).

But when you use Spotify's "shuffle" feature, you'll find that those _trends_ pop up all-too-often.  You'll find that certain songs, somehow, keep creeping up to the top of your playlist.  And other songs _never_ seem to get played.  

If you understand probabilities the way I do (and as a high-stakes poker player, I have some serious experience with this), at first you'll brush these repetitions off as the kind of fleeting coincidences that can occur in a truly _random_ data set.  But after you spend _hundreds of hours_ listening to your playlists, you'll eventually come to understand that these strange coincidences have nothing to do with the vagaries of randomness.
<br/><br/>

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/hf2jvs68ctje366g02vx.jpg)
## The Goal
I thought my "quest" was simple.  I didn't think I was chasing the Holy Grail.  _All I wanted_ was to get a fresh SHUFFLE of my playlists any time I desired. 

What do I mean by "shuffle"??

Well, think of it just like a deck of cards.  Between _every_ poker hand, the cards are thoroughly shuffled.  (In any modern context, this is done by an automatic shuffling machine.)  

This means that every hand is a completely new, completely independent event.  Yes, it's possible that you'll hear the same song that you heard in your last session.  And it's possible that you'll "miss" other songs over multiple sessions.  But I'm perfectly fine with that.  I just want my playlists to be played in a truly _random_ manner.

I want to know that, every time I "shuffle" a playlist, the Humpty Dance _could_ come up as the first song in the mix.  Or... I may not hear it again for awhile.  _That's_ the true nature of randomness.  

But Spotify doesn't work this way.  How do I _know_ that???  Well, I'm glad you asked...
<br/><br/>

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/pvgcr8unqtzt0qbm9y2s.jpg)
## Know-It-Alls
I'm not the only one annoyed with Spotify's not-so-randomness.  Many others have noticed that some of their songs get played _repeatedly_.  While other songs simply never get played.  

If you wanna get a sense for the scope of the problem, just google "spotify shuffle sucks" and behold the massive menu of rage posts.  Their own "community" forum site has many threads complaining about the issue.  One of those threads has _189 pages_ of ongoing comments, spanning back over _years_.

Is this a case of a tone-deaf company completely ignoring an issue?  Not exactly.  This is a case of an arrogant company swearing that they've fixed the issue.  They published this cheeky explanation of their approach way back in 2014 where they graciously congratulate themselves for their high-minded brilliance:

https://engineering.atspotify.com/2014/02/28/how-to-shuffle-songs/

They acknowledge that the "shuffle" algorithm isn't at all random.  They brag about how they've supposedly fixed it by implementing a better algorithm that accounts for peoples' misconceptions about randomness.  And for the last 6+ years, they've stubbornly refused to do anything else about it - even though there are _thousands_ of ongoing complaints across the internet about their super-janky faux shuffler.

But their shuffle algorithm doesn't even work the way that they say it does.  If you spend excruciating amounts of time diving into the behavior of their application, it quickly becomes quite clear that some songs just get repeatedly _ignored_.  

This isn't a case of me seeing nonexistent patterns in the noise.  I can pretty much _prove_ that their "improved", better-than-random algorithm just can't be bothered to play certain songs.  In fact, I put up a repeatable use-case in their own forums.  You can read it here:

https://community.spotify.com/t5/Ongoing-Issues/Please-stop-marking-shuffle-complaints-as-quot-not-an-issue-quot/idc-p/1783738#M49827

You'll also notice that I titled the post in their community forums as `Please stop marking shuffle complaints as "not an issue" or "implemented"`.  I gave it that title, because that's _exactly_ what they do.  

User after user after frustrated user complains about the exact same thing.  And their response is simply to mark the complaint as "not an issue" or "implemented".  For the post above, in which I gave them a detailed write-up of how to recreate the issue, they answered:
<br/>

> We understand your situation!  We're looking into it and we're working on our shuffle algorithm.  Keep an eye on any updates soon.  Take care.

<br/>Then... they marked the ticket as "Not An Issue".
<br/><br/>

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/03nn803pw4gki9u8kfft.jpg)
## A Frustrating Problem
This probably feels like it's just a long angry rant about a particular company that can't be bothered to fix its own software.  But I'm writing this up on Dev.to because there are valuable lessons for us to take from this example as programmers.

Spotify went down this path because people inherently misunderstand randomness.  I get that.  But they decided to fix a "problem" - by introducing another problem.

Most people just don't _grok_ random sequences.  They have 100 songs in their playlist.  Five of those songs are by Justin Bieber.  After the playlist is _randomly shuffled_, they hear two Justin Bieber songs in a row.  And they start thinking: "Heyyy!  _That's_ not random!" But... it _is_. 

If you shuffle your 100-song playlist that has 5 Bieber tracks, it's perfectly possible that you _might_ end up hearing 2 of those tracks in a row.  The same concept is at play when you thoroughly shuffle a deck of playing cards and two aces are dealt out in a row.  It's absolutely possible.  And it doesn't mean that the shuffle wasn't "random".
<br/><br/>

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/jyg0cv2cqbjj71ctqied.jpg)
## Don't Be Like Spotify
To be clear, Spotify was justified in trying to rig their "shuffle" feature.  Because if your users repeatedly _perceive_ that there's a problem in your app, then there _is_ a problem in your app.  It won't do any good to yell at them that they just don't understand randomness.

The mismatch between perception and reality is often most acute whenever we try to implement _random_ features in our apps.  It could be a music playlist.  It could be a "quote of the day".  It could be a game where the damage incurred by your character is calculated as a random die roll.  In all these examples, it's tempting to just slap a random number generator on it and call it a day.  

But if too many of your users _perceive_ that the process isn't random, they may become frustrated to the point that they're no longer your users.  In fact, if they're _really_ frustrated, they may even complain to your potential future users.  In the most extreme cases, you may reach a situation where you simply have no users - even though your random algorithm was mathematically flawless.

So if randomness carries the risk of being misinterpreted by your users, how can you solve the problem?  Well, you _could_ choose to follow the patented Spotify Method:
<br/>

1. Make an obtuse change to your algorithm and brag about it in a blog post.<br/><br/>

1. Offer no options to the user in the UI.<br/><br/>

1. Any time someone complains about the new algorithm, mark their complaint as "Implemented" or "Not An Issue" - without making any changes.<br/><br/>

If this approach doesn't appeal to you, then, congratulations!  You're not a douchebag.  So what other options do you have??  Well... here are some thoughts:
<br/>

**Don't make monolithic decisions for your users.**

Whenever possible, give your users _options_.  I don't mind that Spotify felt it necessary to implement some kind of "enhanced" shuffle algorithm.  That's fine.  But give me the _option_ to turn it off.  Or maybe, somewhere in the "Settings", allow me to actually _choose_ which algorithm I prefer when shuffling.
<br/>

**Don't treat your API as a fix for UX problems.**

I bring this up because Spotify does have an API that will allow tech-types like us to build our own shuffle features.  I eventually solved this by writing my own custom shuffler that leverages their API.  There are a handful of other "Spotify shufflers" out there on the web.  

But this should never be the "answer" to problems inside your app.  It's wonderful if you can manage to supply a robust API that allows users to extend your app's functionality.  But the vast majority of your users will only ever use your app... _inside your app_.  They either don't know how to build API integrations - or they can't be bothered to.  
<br/>

**Be _transparent_ with your algorithms.**

We tend to protect our algorithms more than we protect our children.  But when you have a feature that frustrates your users, that frustration can be multiplied by their ignorance of _how_ the app is actually working.  I'm not saying that you need to hand over your complete code base.  But for something as "magical" as shuffling, it would go a long way toward mollifying your users if you just explain to them - clearly, accurately, and concisely - exactly how the sausage gets made.

The Spotify experience is especially aggravating because, after extensive research and testing, I was able to repeatedly demonstrate that _their algorithm does not work in the way they claim it works_.  And yet, they refuse to do anything about it.  In fact, they refuse to even acknowledge the issue in any way.
<br/>

**Give users a history of past results.**

This can go a long way toward alleviating user frustration.  It's only natural that, when I'm using your battle simulator, it _feels_ to me like I lose at a disproportionate rate.  But if I can view a history of my last 500 battles, it's at least possible that I may look back over that history and realize that the world (your app) isn't truly tilted against me.
<br/>

**Carefully consider if randomness is what you truly _want_ in your app.**

Once you understand that users inherently misunderstand randomness, it's reasonable to ask yourself whether you really want to use randomness at all.  

For example, imagine that my app is an online media player that continually streams a selection of video highlights from local high school athletics.  Let's also imagine that I have a library of 10,000 such clips to choose from.

It would be incredibly simple to just load up the IDs for all 10,000 and then randomly select one after another after another.  But I can almost guarantee that this will lead to complaints from my users.

You see, it's inevitable that, in my random video queue, I'll eventually play two, or three, or four highlights all in a row _from the same high school_.  It's also inevitable that some of my viewers will start griping about the idea that my app is "biased" toward one school, or against their favorite school.

It probably makes more sense to spend some time _categorizing_ the video clips by school, by sport, by player, etc.  Once they're categorized, I can write a more tailored "randomization" algorithm that will take these factors into account before building the video queue.  Yes, that requires more work, and more forethought.  But if it fosters the long-term success of my application, it's well worth it.
<br/><br/>

## Conclusion
In the end, there are some times when "true" randomness is absolutely necessary.  But be warned, it's almost impossible to implement a feature based on randomness that won't lead at least _some_ of your users to complain about the non-randomness (that they perceive). How you choose to address those perceptions will go a long way toward determining the success, and the public acceptance, of your application.