HAMMERSLEY_ADVANCED The Hammersley Quasi Monte Carlo (QMC) Sequence

HAMMERSLEY_ADVANCED is a FORTRAN90 library which computes elements of a Hammersley Quasi Monte Carlo (QMC) sequence.

HAMMERSLEY_ADVANCED includes routines to make it easy to manipulate this computation, to compute the next N entries, to compute a particular entry, to restart the sequence at a particular point, or to compute NDIM-dimensional versions of the sequence.

For the most straightforward use, try either

• I4_TO_HAMMERSLEY, for one element of a sequence;
• I4_TO_HAMMERSLEY_SEQUENCE, for N elements of a sequence;
Both of these routines require explicit input values for all parameters.

For more convenience, there are two related routines with almost no input arguments:

• HAMMERSLEY, for one element of a sequence;
• HAMMERSLEY_SEQUENCE, for N elements of a sequence;
These routines allow the user to either rely on the default values of parameters, or to change a few of them by calling appropriate routines.

Routines in this library select elements of a "leaped" subsequence of the Hammersley sequence. The subsequence elements are indexed by a quantity called STEP, which starts at 0. The STEP-th subsequence element is simply the Hammersley sequence element with index

```        SEED(1:NDIM) + STEP * LEAP(1:NDIM).
```

The arguments that the user may set include:

• NDIM, the spatial dimension,
default: NDIM = 1,
required: 1 <= NDIM;
• STEP, the subsequence index.
default: STEP = 0,
required: 0 <= STEP.
• SEED(1:NDIM), the Hammersley sequence index corresponding to STEP = 0.
default: SEED(1:NDIM) = (0, 0, ... 0),
required: 0 <= SEED(1:NDIM);
• LEAP(1:NDIM), the succesive jumps in the Hammersley sequence.
default: LEAP(1:NDIM) = (1, 1, ..., 1).
required: 1 <= LEAP(1:NDIM).
• BASE(1:NDIM), the Hammersley bases.
default: BASE(1:NDIM) = (2, 3, 5, 7, 11... ),
or (-N, 2, 3, 5, 7, 11,...) if N is known;
required: 1 < BASE(I) for any van der Corput dimension I, or BASE(I) < 0 to generate the fractional sequence J/|BASE(I)|.

In the standard NDIM-dimensional Hammersley sequence, it is assumed that N, the number of values to be generated, is known beforehand. The first dimension of entries in the sequence will have the form J/N for J from 1 to N. The remaining dimensions are computed using the 1-dimensional van der Corput sequence, using successive primes as bases.

In a generalized Hammersley sequence, each coordinate is allowed to be a fractional or van der Corput sequence. For any fractional sequence, the denominator is arbitrary. However, it is extremely desirable that the values in all coordinates stay between 0 and 1. This happens automatically for any van der Corput sequence, but for fractional sequences, this criterion is enforced using an appropriate modulus function. The consequence is that if you specify a small "base" for a fractional sequence, your sequence will soon wrap around and you will get repeated values.

If you drop the first dimension of the standard NDIM-dimensional Hammersley sequence, you get the standard Halton sequence of dimension NDIM-1.

The standard Hammersley sequence has slightly better dispersion properties than the standard Halton sequence. However, it suffers from the problem that you must know, beforehand, the number of points you are going to generate. Thus, if you have computed a Hammersley sequence of length N = 100, and you want to compute a Hammersley sequence of length 200, you must discard your current values and start over. By contrast, you can compute 100 points of a Halton sequence, and then 100 more, and this will be the same as computing the first 200 points of the Halton sequence in one calculation.

In low dimensions, the multidimensional Hammersley sequence quickly "fills up" the space in a well-distributed pattern. However, for higher dimensions (such as NDIM = 40) for instance, the initial elements of the Hammersley sequence can be very poorly distributed; it is only when N, the number of sequence elements, is large enough relative to the spatial dimension, that the sequence is properly behaved. Remedies for this problem were suggested by Kocis and Whiten.

Languages:

HAMMERSLEY_ADVANCED is available in a C++ version and a FORTRAN90 version and a MATLAB version.

Related Data and Programs:

CVT, a FORTRAN90 library which computes elements of a Centroidal Voronoi Tessellation.

FAURE, a FORTRAN90 library which computes elements of a Faure quasirandom sequence.

HALTON, a FORTRAN90 library which computes elements of a Halton Quasi Monte Carlo (QMC) sequence, using a simple interface.

HAMMERSLEY_DATASET, a FORTRAN90 program which creates a Hammersley sequence and write it to a file.

HEX_GRID, a FORTRAN90 library which computes elements of a hexagonal grid dataset.

HEX_GRID_ANGLE, a FORTRAN90 library which computes elements of an angled hexagonal grid dataset.

IEEE_UNIFORM_SAMPLE, a FORTRAN90 library which tries to uniformly sample the discrete set of values that represent the legal IEEE real numbers;

IHS, a FORTRAN90 library which computes elements of an improved distributed Latin hypercube dataset.

LATIN_CENTER, a FORTRAN90 library which computes elements of a Latin Hypercube dataset, choosing center points.

LATIN_EDGE, a FORTRAN90 library which computes elements of a Latin Hypercube dataset, choosing edge points.

LATIN_RANDOM, a FORTRAN90 library which computes elements of a Latin Hypercube dataset, choosing points at random.

LATTICE_RULE, a FORTRAN90 library which approximates multidimensional integrals using lattice rules.

LCVT, a FORTRAN90 library which computes a latinized Centroidal Voronoi Tessellation.

NIEDERREITER2, a FORTRAN90 library which computes elements of a Niederreiter quasirandom sequence with base 2.

NORMAL, a FORTRAN90 library which computes elements of a sequence of pseudorandom normally distributed values.

SOBOL, a FORTRAN90 library which computes elements of a Sobol quasirandom sequence.

UNIFORM, a FORTRAN90 library which computes elements of a uniform pseudorandom sequence.

VAN_DER_CORPUT, a FORTRAN90 library which computes elements of a van der Corput quasirandom sequence.

Reference:

1. John Hammersley,
Monte Carlo methods for solving multivariable problems,
Proceedings of the New York Academy of Science,
Volume 86, 1960, pages 844-874.
Computational Investigations of Low-Discrepancy Sequences,
ACM Transactions on Mathematical Software,
Volume 23, Number 2, 1997, pages 266-294.

List of Routines:

• ARC_COSINE computes the arc cosine function, with argument truncation.
• ATAN4 computes the inverse tangent of the ratio Y / X.
• GET_SEED returns a seed for the random number generator.
• GET_UNIT returns a free FORTRAN unit number.
• HALHAM_LEAP_CHECK checks LEAP for a Halton or Hammersley sequence.
• HALHAM_N_CHECK checks N for a Halton or Hammersley sequence.
• HALHAM_DIM_NUM_CHECK checks DIM_NUM for a Halton or Hammersley sequence.
• HALHAM_SEED_CHECK checks SEED for a Halton or Hammersley sequence.
• HALHAM_STEP_CHECK checks STEP for a Halton or Hammersley sequence.
• HALHAM_WRITE writes a Halton or Hammersley subsequence to a file.
• HAMMERSLEY computes the next element in a leaped Hammersley subsequence.
• HAMMERSLEY_BASE_CHECK checks BASE for a Hammersley sequence.
• HAMMERSLEY_BASE_GET gets the base vector for a leaped Hammersley subsequence.
• HAMMERSLEY_BASE_SET sets the base vector for a leaped Hammersley subsequence.
• HAMMERSLEY_LEAP_GET gets the leap vector for a leaped Hammersley subsequence.
• HAMMERSLEY_LEAP_SET sets the leap vector for a leaped Hammersley subsequence.
• HAMMERSLEY_MEMORY holds data associated with a leaped Hammersley subsequence.
• HAMMERSLEY_DIM_NUM_GET gets the spatial dimension for a leaped Hammersley subsequence.
• HAMMERSLEY_DIM_NUM_SET sets the spatial dimension for a leaped Hammersley subsequence.
• HAMMERSLEY_SEED_GET gets the seed vector for a leaped Hammersley subsequence.
• HAMMERSLEY_SEED_SET sets the seed vector for a leaped Hammersley subsequence.
• HAMMERSLEY_SEQUENCE computes N elements of a leaped Hammersley subsequence.
• HAMMERSLEY_STEP_GET gets the "step" for a leaped Hammersley subsequence.
• HAMMERSLEY_STEP_SET sets the "step" for a leaped Hammersley subsequence.
• I4_TO_HAMMERSLEY computes one element of a leaped Hammersley subsequence.
• I4_TO_HAMMERSLEY_SEQUENCE computes N elements of a leaped Hammersley subsequence.
• I4VEC_TRANSPOSE_PRINT prints an I4VEC "transposed".
• PRIME returns any of the first PRIME_MAX prime numbers.
• U1_TO_SPHERE_UNIT_2D maps a point in the unit interval to the unit circle.
• U2_TO_BALL_UNIT_2D maps points from the unit box to the unit ball in 2D.
• U2_TO_SPHERE_UNIT_3D maps a point in the unit box onto the unit sphere in 3D.
• U3_TO_BALL_UNIT_3D maps points from the unit box to the unit ball in 3D.
• TIMESTAMP prints the current YMDHMS date as a time stamp.

You can go up one level to the FORTRAN90 source codes.

Last revised on 31 December 2010.