1
$\begingroup$

So I carry a thumb drive with me, and play music from a library of a couple thousand songs eight hours a day at work. I don't bother pausing when I get up for break/lunch/meetings, I just mute my headphones. When I start playing music in the morning, it begins exactly where it was when I closed the music player the previous day. In effect, I have created an infinitely looping playlist of a few thousand songs. Most of these songs are the typical 3-4 minutes, while some are video game OST's that can be 4-5 hours long.

I've been wondering, assuming the "random" feature on my media play is truly random how should I calculate the odds of catching a specific song at any given time if I put my headphones in? The randomization does not require all songs to play in the set before it will replay any, it can (and has) played the same song multiple times in a row. I'm thinking that based on the ratio of "long" tracks to regular length tracks, it should lean heavily towards me putting on my headphones during a short song, but it really seems to be about 50/50 of catching a "long" track.

Here's an example data set similar to what I'm trying to calculate on. Obviously, this group would be VERY likely for me to pick it up on a "long" song, but It'd be great to see how the probabilities could be calculated from it.

AC/DC - Back in Black         4:10
AC/DC - Shook me all Night    3:31
The Beatles - Come Together   2:04
Daft Punk - Contact           4:27
FF9 Full OST                325:35
$\endgroup$
  • 1
    $\begingroup$ Think about it like this. If there are two songs, equally likely to be played, and of lengths 1 and 3 minutes, 3/4 of the time, the 3 minute long song will be playing. if you pick a random moment in time, there is a 3/4 probability that the 3 minute long song will be playing. If there are two songs of length 1 minute and 1 of length 3 minutes, 3/5 of the time, a long song would be playing. You should be able to do what you want with thinking along these lines. Look up "length-biased sampling" and "renewal paradox". $\endgroup$ – Mark L. Stone Dec 14 '15 at 18:46
  • $\begingroup$ One wrinkle here is to consider under what circumstances the player will "loop around." (1) For example, if, after finishing a song, the player randomly selects a song from the whole library, then probability of hearing that song again as the next track is $1/n.$ (2) But if your player must play each song once before repeating is permitted, then the probability is a function of how many songs have already been played. You say "assume it's truly random," which implies (1) but I think it's more likely the player exhibits behavior (2) based on my experience with music players. $\endgroup$ – Sycorax says Reinstate Monica Dec 14 '15 at 18:52
  • $\begingroup$ @user777 I'll edit the question for that, but it can (and has on occasion) played the same song twice in a row. $\endgroup$ – Sidney Dec 14 '15 at 18:53
  • $\begingroup$ @user777 Depending on the precise question of Sidney, that doesn't necessarily effect anything. For example, if there is 1 red ball in a 10 ball urn, the probability of the 7th ball being red is 1/10, regardless whether you're sampling with or without replacement. If you don't condition on past information, whether songs can repeat or not doesn't matter. On the other hand, if we're conditioning on what song was just played, it's quite important! $\endgroup$ – Matthew Gunn Dec 14 '15 at 19:04
2
$\begingroup$

The probability of a song being played assuming that the songs are picked from a uniform distribution is equal to $$ P(song) = \frac{Length \ of \ Song}{Length \ of \ all \ Songs} $$

So for the sample dataset, the total time in seconds is $$(4*60 + 10)+(3*60 + 31)+(2*60 + 04)+(4*60 + 27)+(325*60 + 35) = 20387 \ seconds $$

So the probability of your shortest song (The Beatles - Come Together) is $$P(The \ Beatles \ - \ Come \ Together)=\frac{2*60 + 4}{20387} = 0.0061$$ While the probability of your longest song is: $$P(FF9 \ Full \ OST) = \frac{325*60 + 35}{20387} = 0.958$$

In general the longer the song the more likely it is to be playing randomly.

$\endgroup$
  • 2
    $\begingroup$ This is the steady-state answer. When the player is first started, there is a transient period. For instance, at any time during the first 2:04, all 5 songs in the example are equally likely to be playing.. $\endgroup$ – Mark L. Stone Dec 14 '15 at 19:43
  • $\begingroup$ @MarkL.Stone The question asks about "catching a specific song at any given time if I put my headphones in", which assumes a steady state answer. But I agree with you completely, during the transient period the probability of each song is equal. Didn't recall that. Thanks. $\endgroup$ – Armen Aghajanyan Dec 14 '15 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.