10.12.2012 Views

Prime Numbers

Prime Numbers

Prime Numbers

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

8.3 Quasi-Monte Carlo (qMC) methods 411<br />

Algorithm 8.3.6 is usually used in floating-point mode, i.e., with stored<br />

floating-point inverse powers qi,j but integer digits ni,j. However, there is<br />

nothing wrong in principle with an exact generator in which actual integer<br />

powers are kept for the qi,j. In fact, the integer mode can be used for testing of<br />

the algorithm, in the following interesting way. Take, for example, N = 1000,<br />

so vectors x0,...,x999 are allowed, and choose D = 2 dimensions so that the<br />

primes 2,3 are involved. Then call seed(701), which sets the variable x to be<br />

the vector<br />

x701 = (757/1024, 719/729).<br />

Now, calling random() exactly 9 times produces<br />

x710 = (397/1024, 674/729),<br />

and sure enough, we can test the integrity of the algorithm by going back and<br />

calling seed(710) to verify that starting over thus with seed value 701+9 gives<br />

precisely the x710 shown.<br />

It is of interest that Algorithm 8.3.6 really is fast, at least in this<br />

sense: In practice, it tends to be faster even than calling a system’s built-in<br />

random-number function. And this advantage has meaning even outside the<br />

numerical-integration paradigm. When one really wants an equidistributed,<br />

random number in [0, 1), say, a system’s random function should certainly be<br />

considered, especially if the natural tendency for random samples to clump<br />

and separate is supposed to remain intact. But for many statistical studies,<br />

one simply wants some kind if irregular “coverage” of [0, 1), one might say a<br />

“fair” coverage that does not bias any particular subinterval, in which case<br />

such a fast qMC algorithm should be considered.<br />

Now we may get a multidimensional integral by calling, in a very simple<br />

way, the procedures of Algorithm 8.3.6:<br />

Algorithm 8.3.7 (qMC multidimensional integration). Given a dimension<br />

D, and integrable function f : R → R, where R = [0, 1] D , this algorithm<br />

estimates the multidimensional integral<br />

<br />

I = f(x) d D x,<br />

x∈R<br />

via the generation of N0 qMC vectors, starting with the n-th of a sequence<br />

(x0,x1,...,xn,...,xn+N0−1,...). It is assumed that Algorithm 8.3.6 is initialized<br />

with an index bound N ≥ n + N0.<br />

1. [Initialize via Algorithm 8.3.6]<br />

seed(n); // Start the qMC process, to set a global x = xn.<br />

I =0;<br />

2. [Perform qMC integration]<br />

// Function random() updates a global qMC vector (Algorithm 8.3.6).<br />

for(0 ≤ j

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!