Art, Bert and Chaz are on a road trip.
Bert: Hey Art, this is great music!
Art: Thanks! I compiled the play list myself, and wrote my own app to play it.
Chaz: I noticed that all the songs are exactly 4 minutes long, pretty cool!
Bert: Is the song selection random?
Art: Yes, perfectly random using the full list each time a song is selected.
Chaz: I guessed that ā there have been a few repeats.
Art:, True, but not too many ā there are enough songs to last 8 hours.
Bert: Good, Iād like to hear my favorite song again before we stop!
Assuming that the app has just been started:
1) How many songs will Bert have heard before there is a better than 50/50 chance he will hear his favorite song?
2) How long on average would Bert have to wait to hear his favorite song twice?
3) How many songs would have to be in the playlist so that it is greater than a 50/50 chance Bert will NOT hear his favorite song in 4 hours?
4) BONUS: Art rewrites his app such that songs already played have a 50% reduced chance of being selected again vs. an unplayed song (until the full list is played). Answer questions 2-3 again.
There are 120 songs in the playlist (8*60/4).
The probability he won't hear his song in the first n songs is
(119/120)^n
and the probability he will hear it in that time is 1-(119/120)^n. And n songs take 4*n minutes.
minutes probability of having heard his song
4 0.008333
8 0.016597
12 0.024792
16 0.032919
20 0.040978
24 0.048970
28 0.056895
32 0.064754
36 0.072548
40 0.080277
44 0.087941
48 0.095542
52 0.103079
56 0.110553
60 0.117965
64 0.125315
68 0.132605
72 0.139833
76 0.147001
...
280 0.443327
284 0.447966
288 0.452566
292 0.457128
296 0.461652
300 0.466138
304 0.470587
308 0.474999
312 0.479374
316 0.483713
320 0.488015
324 0.492282
328 0.496513
332 0.500708
At 332 minutes, Bert will have slightly greater than 1/2 probability of having heard his song.
Part 2 is an expected value problem. The harder part is finding the expected value of the first hearing; double that is the expected value of hearing it twice.
The probability of hearing it for the first time on try n is (119/120)^(n-1) / 120 = 119^(n-1)/120^n. Then sum to "infinity" these values multiplied by the 4 minute play time of each. But actually, as 120*4 = 480, each song has 480 minutes as the expected value of how long it will take, and to hear two, the expected value is 960 minute. These are 8 and 16 hours respectively. Summing the given formula does indeed approach 480 for the first hearing.
960 minutes is 16 hours, twice the length of the entire collection.
Part 3:
We need ((x-1)/x)^60 to just exceed 0.5. Asking Wolfram Alpha to
solve ((x-1)/x)^60=0.5
gives x ~= 87.0627, and we want to increase the chance of his not hearing the song, go with a collection of 88:
>> for x= 87:88 disp([x ((x-1)/x)^60])
end
87 0.499748981279189
88 0.50372653400965
Part 4, Bonus
part 4.2
totTook=0;
for trial=1:100000
had=zeros(1,120);
selNo=0;
while had(1)<2
selNo=selNo+1;
song=randi(120);
while had(song)>0
if rand>.5
song=randi(120);
else
break
end
end
had(song)=had(song)+1;
end
totTook=totTook+selNo;
end
disp([totTook trial totTook/trial])
finds an average of about just under 230 songs or 919 minutes = 15.3 hours. (when looking only for the first occurrence, it was about 90 songs or 360 minutes or 6 hours.)
Part 4.3
Calling this:
numSongs=100; succ=0;
for trial=1:100000
had=zeros(1,numSongs);
selNo=0;
while selNo<60
selNo=selNo+1;
song=randi(numSongs);
while had(song)>0
if rand>.5
song=randi(numSongs);
else
break
end
end
had(song)=had(song)+1;
end
if had(1)>0
succ=succ+1;
end
end
disp([succ trial succ/trial])
multiple times, with numSongs=100 the success rate of hearing the song is consistently just above 50%; with numSongs=101, it's consistently below. So 101 is the number of songs so Bert has a less than 50% chance of hearing his song.
|
Posted by Charlie
on 2022-04-28 09:08:10 |