|
From: Richard G. <Ric...@ma...> - 2006-02-06 00:57:57
|
Hi
I've been looking at using the Sobol number generator class in QuantLib for=
running parallel monte-carlo simulations across many CPUs. I've modified t=
he constructor to take an extra argument to the constructor to skip ahead i=
n the sequence and thought you might want to consider adding this an extens=
ion to the interface. The code I used is as follows and will scale as O[log=
_2(N)] where N is the number of events to skip at the start of the sequence:
// initialize the Sobol integer/double vectors
// first draw
unsigned long N =3D skip+1;
unsigned int ops =3D ((unsigned int)(log(N)/M_LN2))+1;
// Convert to Gray code
unsigned long G =3D N ^ (N>>1);
for (k=3D0; k<dimensionality_; k++)
{
integerSequence_[k] =3D 0;
for(index=3D0; index<ops; index++)
{
if(G>>index & 1)
integerSequence_[k] ^=3D directionIntegers_[k][index];
}
}
sequenceCounter_ =3D skip;
Regards
Richard Gould
NOTICE=20
The information contained in this email is confidential. If you are not the=
intended recipient, you must not disclose or use the information in this e=
mail in any way. If you received it in error, please tell us immediately by=
return email and delete the document. We do not guarantee the integrity o=
f any e-mails or attached files and are not responsible for any changes mad=
e to them by any other person.
|