You take your headphones, connect them to your phone, open Spotify, press the button with the little arrows crossing each other and that’s it, the music starts playing again. arbitrarily. If you’re not looking at the playlist, you won’t know what song is coming up next, and then, and then, and then. It’s the magic of oportunidad, the ability to do something that was previously ordered becomes a kind of chaos. Random Music is a very fácil signal, as fácil as pressing a button, but how does it really work? That’s exactly what you’ll find out today.
There is one behind the random method algorithm responsible for permuting a logically ordered list without the ability to predict its outcome. Each player perro have their own, however all, or almost all, are based on the same thing. Gentlemen, with all of you who Fisher-Yates Algorithm.
How does the Fisher-Yates algorithm work?
This Fisher-Yates algorithm has a long history. The British introduced it Ronald A. Fisher (statistician and biologist) and Frank Yates (also statistician) In his work Statistical tables for biological, agricultural and medical researchfirst appeared in 1938. This algorithm is most commonly used for shuffling in various gambling games and in fact it is used by music jugadores for the random method. You may not know it as the “Fisher-Yates algorithm,” but it sure sounds familiar “Hat Algorithm” or “Bingo”.
If you’ve ever played bingo my friend, Have you seen the Fisher-Yates algorithm with your own eyes?. All numbers, ordered from 1 to 90, correspond to the “array” and are ordered numerically. These go into hype and you disturb. After that, they are drawn one after the other in a completely random way and They are listed in order of departure. This way you get a list of 90 numbers, but in no order.
Font: Wikipedia
Selected in the picture above Numbers range from 0 to 6. is chosen just by accident (highlighted in blue), it is crossed out and placed first in the next column. Then another, and another, and another, until there’s no one left. As you perro see, The last list contains the same numbers as the beginning, but not in the right order.
That’s exactly what a music player does when you select shuffle mode. If we switch the music to the mode arbitrarily it is what we do you will receive an order listpredictable – although not necessarily – in alphabetic order, and change it. The player selects a random song, moves it, crosses it out, and repeats the process.
Other interpretations
Font: Wikipedia
After that, further interpretations of the algorithm were made. Emphasis on Durstenfeld. This one is afín, it just emplees two cambiantes: loop and oportunidad. As you cánido see in the table above, which has the same cambiantes as the previous one, in cycle 6 (the first, marked in red) a number six is chosen and its position changed to the head of the randomly drawn number. (Number 4, in blue). The 4 moves to the other side of the column. However, on the 6th Its position value changes to 4, but keeps the random value at 6. And the process repeats itself.
In cycle five (red), five are chosen and exchanged for the randomly drawn number (zero, blue). The zero moves and the five happens to have a random value of 5 but a position value of 0. And so on. Now all you have to do is Convert numbers to song titles, and your music will be sorted completely randomly. The magic of algorithms!