Some time has passed since
Lighthouse Crossed Three Lights Muse and each lighthouse has developed a glitch. Now, instead of switching off when it should, the light will (50% of the time) stay on for an extra time period.
The extra time is exactly 1 second for the 1st lighthouse, exactly 2 seconds for the 2nd, and exactly 3 seconds for the 3rd.
In summary:
- The first light shines for 3 or 4 seconds, then is off for 3 seconds.
- The second light shines for 4 or 6 seconds, and then is off for 4 seconds.
- The third light shines for 5 or 8 seconds, then is off for 5 seconds.
What is the expected value of the first time all the lights will be off at the same time?
totTime=0;
for trial=1:10000000
LOn= true(1,3);
LTime=zeros(1,3);
t=0;
while sum(LOn)
t=t+1;
for wh=1:3
LTime(wh)=LTime(wh)+1;
if LOn(wh)
if LTime(wh)==wh*2+2
LOn(wh)=false; LTime(wh)=0;
continue
end
if LTime(wh)==wh+2 && randi(2)==1
LOn(wh)=false; LTime(wh)=0;
continue
end
else
if LTime(wh)==wh+2
LOn(wh)=true;
LTime(wh)=0;
end
end
end
end
totTime=totTime+t;
end
totTime
totTime/trial
produces
>> lighthouseKerfuffle
totTime =
151704035
ans =
15.1704035
>>
indicating an expected timeof 15.17 seconds.
|
Posted by Charlie
on 2023-12-03 08:51:53 |