Htcount 1 end htcount 1 at least one head has

Info icon This preview shows pages 4–5. Sign up to view the full content.

View Full Document Right Arrow Icon
ht_count = 1; end % ht_count = 1; at least one head has occurred else % if tails, increment ht_count if (flip == 0), ht_count = 2; end end end Averaging the waiting time over 10000 independent trials gives a value close to 4. This is lower than the average waiting time for HH, which is 6. The reason is that the HT program never makes negative progress in the sense that ht count never decreases. It either increases or stays constant at every step. In contrast, the heads variable in the HH program can decrease as well as increase: it “starts over” if it sees an H followed by a T. This might be easier to see if we express the MATLAB code as a state transition diagram: 4
Image of page 4

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
H start done H T H H T start done H T H T The left diagram detects HH and the right one detects HT. We see that the left one can backtrack, while the right one never returns to a state once it leaves it. This explains the difference. 5
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern