
Originally Posted by
Paulo1913
Hi
The following is a practise test I am doing:
John is collecting a set of 4 Native Birds cards, from Oatie Flakes cereal packets.
The manufacturers of Oatie Flakes found that some of their machines malfunctioned and 20% of the packets of cereal contain 2 Native Birds cards instead of 1 card.
1. Design a simulation to predict the number of packets of Oatie Flakes that are required to obtain a full set of Native Birds cards.
Describe the simulation in sufficient detail so that another person could repeat it without your help.
Does anyone have any thoughts as to how I should do it?
Something like the following will give you an array containing a sample of the number of boxes needed to obtain a full set
Code:
Ncases=100
outputs=zeros(1,Ncases)
for idx=1 to Ncases
outputs(idx)=Npackets
end
//======================
function Npackets
nn=0 //number of distinct cards held
cards=zeros(1,4) //array with 1's for held cards 0's otherwise
while nn<4 // loop untill full set held
xx=random;
card=RandomInteger(1,4) //first card in packet
cards(card)=1
if xx<0.2
card=RandomInteger(1,4) //second card if present
cards(card)=1
end
nn=sum(cards) //total number of distinct cards
end
return nn
endfunction RonL