Shuffle is supposed to play our music in a random order. But a truly random algorithm would pick any song from any album, and this might result in two or three songs in a row from the same artist, particularly if we have a lot of content from that artist. This doesn’t feel random to the user, so most shuffle algorithms try to ensure that consecutive songs are from different artists and albums. Some algorithms go further and only choose songs from the last 100 you listened to, with the intention of presenting more of the songs you prefer. In fact, this ‘random’ list may be exactly repeated if you keep listening!
[Source: BBC Science Focus]