MATH 375 -- Probability and Statistics 1
Tossing two coins simulation.
September 8, 2003
> | read "/home/fac/little/public_html/ProbStat/MaplePackage/MSP.map"; |
The DieRoll procedure in our Maple package generates a list corresponding
to any number of ``rolls'' of a ``fair die with any number of faces''.
(This is done via the ``random number generator'' I mentioned very briefly
last time.) To simulate a 2-sided coin, we make the number of ``faces'' be 2,
and we generate two lists, FC = first coin, SC = second coin. We interpret
results as 1 = heads, 2 = tails.
> | FC:=DieRoll(10000,2): |
> | SC:=DieRoll(10000,2): |
Now we just count up the total number of times each simple event is
observed:
> | HHCount:=0: HTCount:=0: THCount:=0: TTCount:=0: |
> | for i to 10000 do if FC[i] = 1 and SC[i] = 1 then HHCount:=HHCount+1; end if; if FC[i] = 1 and SC[i] = 2 then HTCount:=HTCount+1; end if; if FC[i] = 2 and SC[i] = 1 then THCount:=THCount+1; end if; if FC[i] = 2 and SC[i] = 2 then TTCount:=TTCount+1; end if; end do: |
> | HHCount; HTCount; THCount; TTCount; |
This indicates that the probability of each simple event HH, HT, TH, TT should be .25.