Random Points on a Uniform Grid

**GRID**
is a Python library which
randomly selects N distinct
points on a uniform grid in the unit hypercube in M-dimensional space.

Note that, unless N is an Mth power of an integer, the program must generate a regular grid with too many points, and then omit some. Choosing which points to omit is done with a random number generator, whose actions are controlled by SEED.

The actual placement of the grid within the unit hypercube leaves some options for the use. It is easiest to describe the options in the 1 dimensional case, and in terms of where the first and last grid point are. Assuming we have N evenly spaced points to place between 0 and 1, the centering options are

- CENTER = 1: first point is 0.0, last point is 1.0;
- CENTER = 2: first point is 1/(N+1), last point is N/(N+1);
- CENTER = 3: first point is 0, last point is (N-1)/N;
- CENTER = 4: first point is 1/N, last point is 1;
- CENTER = 5: first point is 1/(2*N), last point is (2*N-1)/(2*N);

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

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

BALL_GRID, a Python library which computes grid points that lie inside a ball.

DISK_GRID, a Python library which computes grid points that lie inside a disk of user specified radius and center in 2D, using GNUPLOT to create an image of the grid.

ELLIPSE_GRID, a Python library which computes grid points that lie inside an ellipse.

ELLIPSOID_GRID, a Python library which computes grid points that lie inside a 3D ellipsoid.

HALTON, a Python library which computes elements of a Halton quasirandom sequence.

HAMMERSLEY, a Python library which computes elements of a Hammersley quasirandom sequence.

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

PYRAMID_GRID, a Python library which computes a grid of points over the interior of the unit pyramid in 3D;

SIMPLEX_GRID, a Python library which generates a regular grid of points over the interior of an arbitrary simplex in M dimensions.

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

TETRAHEDRON_GRID, a Python library which computes a tetrahedral grid of points.

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

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

- grid_generate.py, generates a grid dataset.
- grid_side.py, finds the smallest M-D grid containing at least N points.
- ksub_random2.py, selects a random subset of size K from a set of size N.
- r8_uniform_01.py, returns a double precision pseudorandom number.
- r8mat_transpose_print.py, prints an R8MAT, transposed.
- r8mat_transpose_print_some.py, prints some of an R8MAT, transposed.
- r8mat_write.py, writes an R8MAT file.
- timestamp.py, prints the current YMDHMS date as a timestamp.
- tuple_next_fast.py, computes the next element of a tuple space, "fast".

- grid_test.py, calls all the tests.
- grid_test.sh, runs all the tests.
- grid_test_output.txt, the output file.

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