drunkard - The 1D Drunkard Some scientific algorithms...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 The 1D Drunkard --- -- -------- Some scientific algorithms require random numbers as input. However, with modern inexpensive computers, which do not have error detecting RAM memory, it is also important to be able to repeat computer runs, in order to check that they are correct. A solution is to use a pseudo-random number generator that produces an apparently random but actually repeat- able series of numbers. The following is a classic pseudo-random number genera- tor: r(0) = seed/* must not be zero */ r(i+1) = r(i) * (7**5) mod (2**31 - 1) where 7**5 = 16807 2**31 - 1 = 2147483647 0 < seed < 2147483647 Here r(0), r(1), r(2), ... is the sequence of pseudo- random numbers generated. Because 2**31 - 1 is prime, this sequence is 2**31 - 2 numbers long before it re- peats. This particular sequence has been extensively tested and found to do very well in common tests of randomness. r You are asked to use this random number generator to simulate a drunkard's walk in a one dimensional world. The drunkard starts at position zero. A random number is acquired. If that is odd, the drunkard `steps right' by adding 1 to his current position. If it is even, the drunkard `steps left' by subtracting 1 from his current position. Successive steps are taken as successive ran- dom numbers are acquired.
Image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
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