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.

410 Chapter 8 THE UBIQUITY OF PRIME NUMBERS<br />

Algorithm 8.3.6 (Fast qMC sequence generation). This algorithm generates<br />

D-dimensional Halton-sequence vectors. Let p1,...,pD denote the first D<br />

primes. For starting index n, aseed() procedure creates xn whose components are<br />

for clarity denoted by xn[1],...,xn[D]. Thenarandom() function may be used<br />

to generate subsequent vectors xn+1,xn+2,..., where we assume an upper bound<br />

of N for all indices. For high efficiency, global digits (di,j) are initially seeded to<br />

represent the starting index n, then upon subsequent calls to a random() function,<br />

are incremented in “odometer” fashion for subsequent indices exceeding n.<br />

1. [Procedure seed]<br />

seed(n) { // n is the desired starting index.<br />

}<br />

for(1 ≤ i ≤ D) {<br />

<br />

ln(N+1)<br />

Ki = ln ; // A precision parameter.<br />

pi<br />

qi,0 =1;<br />

k = n;<br />

x[i] =0; // x is the vector xn.<br />

for(1 ≤ j ≤ Ki) {<br />

qi,j = qi,j−1/pi; // qi,j = p −j<br />

i .<br />

di,j = k mod pi; // The di,j start as base-pi digits of n.<br />

k =(k− di,j)/pi;<br />

x[i] =x[i]+di,jqi,j;<br />

}<br />

}<br />

return; // xn now available as (x[1],...,x[D]).<br />

2. [Function random]<br />

random() {<br />

for(1 ≤ i ≤ D) {<br />

for(1 ≤ j ≤ Ki) {<br />

}<br />

}<br />

di,j = di,j +1; // Increment the “odometer.”<br />

x[i] =x[i]+qi,j;<br />

if(di,j

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

Saved successfully!

Ooh no, something went wrong!