# GRID Random Points on a Uniform Grid

GRID is a FORTRAN90 library which randomly selects N 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);

### Languages:

GRID 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:

CLENSHAW_CURTIS_RULE, a FORTRAN90 library which can set up a Clenshaw Curtis quadrature grid in multiple dimensions.

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

DISK_GRID, a FORTRAN90 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.

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

GRID_DATASET, a FORTRAN90 program which allows the user to specify a grid dataset.

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

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

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.

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.

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

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

SPHERE_GRID, a FORTRAN90 library which provides a number of ways of generating grids of points, or of points and lines, or of points and lines and faces, on the surface of the unit sphere in 3D.

TRIANGLE_GRID, a FORTRAN90 library which computes a triangular grid of points.

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.

### List of Routines:

• GET_SEED returns a seed for the random number generator.
• GET_UNIT returns a free FORTRAN unit number.
• GRID_GENERATE generates a grid dataset.
• GRID_SIDE finds the smallest grid containing at least N points.
• I4_HUGE returns a "huge" I4.
• KSUB_RANDOM2 selects a random subset of size K from a set of size N.
• R8_UNIFORM_01 returns a unit pseudorandom R8.
• R8MAT_WRITE writes an R8MAT file.
• TIMESTAMP prints the current YMDHMS date as a time stamp.
• TUPLE_NEXT_FAST computes the next element of a tuple space, "fast".

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

Last revised on 13 December 2009.