Park Miller Method

This forum is to discuss the book "C++ design patterns and derivatives pricing."

Park Miller Method

Postby G_CAM » Mon Dec 09, 2013 2:49 pm

Hi Mark,

I took a look at Park & Miller's 1988 publication in Communications of the ACM. It turns out they refer to this algorithm rather as Schrage's algorithm in a publication of Schrage in 1979 and Bratley, Fox and Schrage in 1983.

A seed of 0 should be avoided as it will generate a non-random series of 0's. Hence a constructor should test whether the seed is not set to 0 as correctly done in your book. However, the large pirme number in the algorithm (the largest long) 2147483647 will result in a non-random series of 0's as well when used as a seed. If one gives as input (2*n+1)*2147483647 + n*2 (with n = 1,2,3,...) then one also get's a non-random series of 0's because of the Overflow of the long into 2147483647. However for these ones the compiler will give a warning.

In fact one should add an additional test to check whether in the unlikely event a user has set the seed to 2147483647 (software testers like to explore the boundaries though).
G_CAM
 
Posts: 10
Joined: Mon Aug 12, 2013 12:46 pm

Re: Park Miller Method

Postby mj » Fri Dec 13, 2013 9:40 am

The easiest solution is simply not to use Park Miller. I only used it because it was simple and I wanted to provide complete code in the book.

These days most people just download a mersenne twister...
mj
Site Admin
 
Posts: 1380
Joined: Fri Jul 27, 2007 7:21 am


Return to C++ design patterns and derivatives pricing

Who is online

Users browsing this forum: No registered users and 1 guest

cron