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

Info iconThis 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. The first random number acquired is the seed, and thereafter the equation
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/29/2011 for the course IT 201 taught by Professor K.v.arya during the Spring '11 term at IIT Kanpur.

Page1 / 5

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

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online