hammersley, a Python code which computes elements of a Hammersley Quasi Monte Carlo (QMC) sequence using a simple interface.

The standard M-dimensional Hammersley sequence based on N is simply composed of a first component of successive fractions 0/N, 1/N, ..., N/N, paired with M-1 1-dimensional van der Corput sequences, using as bases the first M-1 primes.

The HAMMERSLEY function will return the M-dimensional element of this sequence with index I.

The HAMMERSLEY_SEQUENCE function will return the M-dimensional elements of this sequence with indices I1 through I2.

The HAMMERSLEY_INVERSE function accepts an M-dimensional value, presumably computed by HAMMERSLEY, and returns its original index I.


The computer code and data files described and made available on this web page are distributed under the MIT license


hammersley is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.

Related Data and Programs:

halton, a Python code which computes elements of a Halton Quasi Monte Carlo (QMC) sequence.

latin_random, a Python code which computes elements of a Latin Hypercube dataset, choosing points at random.

normal, a Python code which computes elements of a sequence of pseudorandom normally distributed values.

pdflib, a Python code which evaluates Probability Density Functions (PDF's) and produces random samples from them, including beta, binomial, chi, exponential, gamma, inverse chi, inverse gamma, multinomial, normal, scaled inverse chi, and uniform.

prob, a Python code which evaluates, samples, inverts, and characterizes a number of Probability Density Functions (PDF's) and Cumulative Density Functions (CDF's), including anglit, arcsin, benford, birthday, bernoulli, beta_binomial, beta, binomial, bradford, burr, cardiod, cauchy, chi, chi squared, circular, cosine, deranged, dipole, dirichlet mixture, discrete, empirical, english sentence and word length, error, exponential, extreme values, f, fisk, folded normal, frechet, gamma, generalized logistic, geometric, gompertz, gumbel, half normal, hypergeometric, inverse gaussian, laplace, levy, logistic, log normal, log series, log uniform, lorentz, maxwell, multinomial, nakagami, negative binomial, normal, pareto, planck, poisson, power, quasigeometric, rayleigh, reciprocal, runs, sech, semicircular, student t, triangle, uniform, von mises, weibull, zipf.

randlc, a Python code which generates a sequence of pseudorandom numbers, used by the NAS Benchmark programs.

random_data, a Python code which uses a random number generator (RNG) to sample points corresponding to various probability density functions (PDF's), spatial dimensions, and geometries, including the M-dimensional cube, ellipsoid, simplex and sphere.

random_sorted, a Python code which generates vectors of random values which are already sorted.

rnglib, a Python code which implements a random number generator (RNG) with splitting facilities, allowing multiple independent streams to be computed, by L'Ecuyer and Cote.

sobol, a Python code which computes elements of a Sobol quasirandom sequence.

uniform, a Python code which computes elements of a uniform pseudorandom sequence.

van_der_corput, a Python code which computes elements of a 1D van der Corput Quasi Monte Carlo (QMC) sequence using a simple interface.


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

Source Code:

Last revised on 02 October 2016.