PDA

View Full Version : iPod's Randomness


Sigma
02-20-2005, 12:02 AM
Many have questioned whether the iPod's shuffle feature is random since many have stated that sometimes when they are listening to music using the shuffle feature that they will hear three or more songs from the same album which does not seem very random. What does everyone think about the shuffle's randomness? Apple has insisted that their algorithm is random.

Here are my assumptions:
2000 songs in the library, 30 songs per listening, 13 songs per album

P(having 3 or more songs from album A in the list of 30) = 1 - P(having 0,1,2 songs from album A in the list of 30) = 1 - [ (1987c30)*(13c0) + (1987c29)*(13c1) + (1987c28)*(13c2) ]/(2000c30) = 0.0007877711
Where (XcY) = X!/[Y!(X-Y)!]

But this only gives the probability that at least 3 songs from one given album is not in the list. We are looking for the probability that at least 3 songs from EVERY album is not on the list. Is there some mathematical software that can compute these numbers?

If this probability is even .05, then after listening to 30 different random lists of 30 songs, then probability that you would hear at least 3 songs from one album at least once during the 30 listenings would be almost 80 percent. At this point, we could conclude that it is likely to eventually hear at least 3 songs from the same album during some listening. If this topic shouldn't even be on 2+2, just let me know and I will delete it.

Paul2432
02-20-2005, 03:57 PM
Welcome to the forum. Non-poker probability problems are posted here occassionally.

I don't have an exact solution, but I think I can give a reasonable approximation.

2000 songs / 13 song/album ~= 153 albums.

The number of unique triplets of three songs from the same album is 153 x 13C3.

Each of these triplets can be paired with 1997C27 other songs. The total number of 30 song groups is 2000C30 so the proportion of 30 song listing containing a three songs from the same album is [153 x 13C3 x 1997C27] / [2000C30].

Unless I made an arithmetic error, the above works out to around 0.13.

Of course the problem with the above is that it double counts. The 1997C27 part of the equation will contain some triplets as well. It will also contain additional songs from the same album. Here is where the approximation comes in. I figure approximately 25% of the 1997C27 will be double counts.

So the overall frequency should be 0.75 * 0.13 = 10%.

I am curious how close my solution is to reality so I am going to program a simulation.

I'll post the results of that later.

Paul

bobbyi
02-20-2005, 05:05 PM
In practice, you should get a same-album trifecta more frequently than this model suggests since some albums have a lot more songs than others.

Paul2432
02-20-2005, 05:18 PM
OK. I ran the simulation. I am getting a result of a little more than 11%.

I used VBA code in Microsoft Excel to run the simulation. I have pasted the code below. If anyone sees an error please let me know.

Paul

Option Explicit

Dim song(2002), i, j, count(154), total, temp As Long
Dim pass As Boolean

Dim test As Double

Sub ipod()

total = 0

For j = 1 To 10000

'initialize
pass = False
For i = 1 To 2002
song(i) = (i - 1) \ 13 + 1
Next i
For i = 1 To 154
count(i) = 0
Next i

'select 30 songs
For i = 1 To 30
test = Int(Rnd() * (2003 - i)) + i
temp = song(test)
song(test) = song(i)
song(i) = temp
count(song(i)) = count(song(i)) + 1
Next i

'check for triplets
For i = 1 To 154
If count(i) > 2 Then pass = True
Next i
If pass Then total = total + 1
Next j
MsgBox (total)

End Sub

gaming_mouse
02-20-2005, 08:38 PM
The simple answer is yes, I'm sure it is very close to random, as creating a good random number generator is not that hard. But to answer your question...

For simplicity, assume there are 154 albums with 13 songs each, for a total of 2002 songs. Let:

A1 = the event that 3 or more songs are played from album 1
A2 = same thing for albuem 2.
etc...

We want P(A1 or A2 or A3 .... or A154)

We'll use the first 2 terms of the inclusion-exclusion expansion to get a very good approximation to the answer.

Note that P(A1) = P(A2) = ... = P(A154)

P(A1) = 1 - P(exactly 0 or exactly 1 or exactly 2 songs from album1)

P(exactly 0) = (1989 choose 30)/(2002 choose 30)
P(exactly 1) = (13*(1989 choose 29))/(2002 choose 30)
P(exactly 2) = ((13 choose 2)*(1989 choose 28))/(2002 choose 30)

Thus P(at least 3 from album 1) = 0.000785492

The first term of inclusion-exclusion is therefore 154*0.000785492 = 0.120965768

Now we need to work on getting info for the second term of inclusion-exclusion. We note that:

P(>=3 from A1 & >=3 from A2) < P(>=3 from A1)^2

Thus the second term in inclusion-exclusion is less than:

(154 choose 2)*0.000785492^2=0.00726884969

The answer is therefore 0.120965768 plus or minus 0.00726884969, about 12%

This means that it is quite possible to see 3 songs from the same album even for a perfectly random shuffle.

HTH,
gm