Fred has five dice and decides to see how long it will take him
to throw five 6s using the following
procedure. He tosses all five dice.
He then picks up and re-tosses those
that are not 6s. He repeats this process
until he has all 6s.
What is the
expected number of tosses to get five
6s? Give the answer exactly in terms
of a fraction.
The program produces a list of expected values of the numbers of tosses that will be required to complete a set of n 6's, starting with n = 1 die.
The list is needed as each toss can reduce the number remaining to be tossed; the list enables one to calculate the added number of tosses expected beyond those already
done.
The program calculates the probability, at each stage of n remaining dice, that 1 through n-1 will still remain to be converted to a 6. Then the probabiliy that none will remain (all the remaining dice will succeed) is calculated separately, mainly because Matlab doesn't have a zero allowed as a subsctipt. What's then left from a probability of 1 is the probability that all n are still unconverted (i.e., none were successfully tossed to a 6).
This enables an equation to be solved where the expected value for n equals the 1 plus the expected weighted average of the possible outcomes of the toss; that includes the possibility that all n will still be needed to be tossed, so x (i.e. expectation for n) appears on both sides of the equation.
clearvars
expect(1)= sym(6);
for n= 2:6
p=sym(zeros(1,n-1));
for i=1:n-1 % i remain to go
p(i)=(sym(1/6)^(n-i) * sym(5/6)^(i) * nchoosek(n,i));
end
s=sum(p);
p0=sym(1/6^n);
pn=1-s-p0;
syms x
eq=x==pn*x +1 +sum(p.*expect(1:n-1));
sln=solve(eq,x);
expect(n)=sln;
end
expect
fprintf('%19.14f ',eval(expect))
As a bonus the iteration was continued to n=6.
The required answer, for n = 5, however, is 3698650986/283994711.
For comparison with results of a simulation, this amounts to approximately 13.02366150755533.
The output shows first the rational expectation for n = 1 througn 6, and then the decimal approximation:
expect =
[6, 96/11, 10566/1001, 728256/61061, 3698650986/283994711, 9438928992/677218157]
6.00000000000000
8.72727272727273
10.55544455544456
11.92669625456511
13.02366150755533
13.93779669732039
The simulation of a million trials is in line with the value found. The simulation result was 13.021884.
tosses=0; for trial=1:1000000
remain=5;ct=0; while remain>0
n=randi(6,[1,remain]); sixes=length(n(n==6)); remain=remain-sixes;
ct=ct+1;
end
tosses=tosses+ct;
end
tosses/trial
ans =
13.021884
Extended to 10 dice:
expect =
[6, 96/11, 10566/1001, 728256/61061, 3698650986/283994711, 9438928992/677218157,
22975480258221270618504974257094656
/1560692013563158994140180178060297,
1143492447377186907392469748593096053874430830157131231002624
/74219292685716736705466606994214805587960715385458803258717,
26393514320559792551087592819531619535147928860111673114163653886673366955883552047104
/1647908899479376939407561510162615345460573755580155155683694484719632603775703232351,
714843726001007145719100762175281651673177622690605025937626884716029149658068854686218801523541029226546460622848
/43154255857584567590276374676446718984252956150934574464367873263293692160040509820656720667052740158183091175457]
6.00000000000000
8.72727272727273
10.55544455544456
11.92669625456511
13.02366150755533
13.93779669732039
14.72134159626203
15.40694347788157
16.01636736648384
16.56484886125941
Edited on February 5, 2025, 9:02 am
|
Posted by Charlie
on 2025-02-05 08:56:30 |