# NORMAL_DATASET Generate Multivariate Normal Random Datasets

NORMAL_DATASET is a FORTRAN90 program which creates a multivariate normal random dataset and writes it to a file.

The multivariate normal distribution for the M dimensional vector X has the form:

pdf(X) = (2*pi*det(A))**(-M/2) * exp(-0.5*(X-MU)'*inverse(A)*(X-MU))

where MU is the mean vector, and A is a positive definite symmetric matrix called the variance-covariance matrix.

To create X, an MxN matrix containing N samples from this distribution, it is only necessary to

1. create an MxN vector Y, each of whose elements is a sample of the 1-dimensional normal distribution with mean 0 and variance 1;
2. determine the upper triangular Cholesky factor R of the matrix A, so that A = R' * R;
3. compute X = MU + R' * Y.

### Usage:

normal_dataset m n seed mu a
where
• m is the spatial dimension;
• n is the number of points to generate;
• seed is the initial seed value;
• mu is the mean vector, of length m;
• a is the positive definite symmetric variance-covariance matrix of dimension m by m.
The data is written to the file normal_m_n.txt.

Although m, n, and seed may be entered on the command line, it probably makes more sense to enter the vector mu and the matrix a interactively.

### Languages:

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

### Related Data and Programs:

CVT_DATASET, a FORTRAN90 program which computes a Centroidal Voronoi Tessellation and writes it to a file.

CVT_MOD_DATASET, a FORTRAN90 program which creates a CVT dataset on the unit square with no boundaries (a logical torus);

FAURE_DATASET, a FORTRAN90 program which creates a Faure quasirandom dataset;

GRID_DATASET, a FORTRAN90 program which creates a grid sequence and writes it to a file.

HALTON_DATASET, a FORTRAN90 program which creates a Halton sequence and writes it to a file.

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

HEX_GRID_DATASET, a FORTRAN90 program which creates a hexagonal grid dataset and writes it to a file.

IHS_DATASET, a FORTRAN90 program which creates an improved distributed Latin hypercube dataset and writes it to a file.

LATIN_CENTER_DATASET, a FORTRAN90 program which creates a Latin Center Hypercube dataset;

LATIN_EDGE_DATASET, a FORTRAN90 program which creates a Latin Edge Hypercube dataset;

LATIN_RANDOM_DATASET, a FORTRAN90 program which creates a Latin Random Hypercube dataset;

LCVT_DATASET, a FORTRAN90 program which computes a latinized Centroidal Voronoi Tessellation and writes it to a file.

NIEDERREITER2_DATASET, a FORTRAN90 program which creates a Niederreiter quasirandom dataset with base 2;

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

SOBOL_DATASET, a FORTRAN90 program which computes a Sobol quasirandom sequence and writes it to a file.

UNIFORM_DATASET, a FORTRAN90 program which generates a dataset of uniform pseudorandom values and write them to a file.

VAN_DER_CORPUT_DATASET, a FORTRAN90 program which creates a van der Corput quasirandom sequence and writes it to a file.

### Reference:

1. Paul Bratley, Bennett Fox, Linus Schrage,
A Guide to Simulation,
Springer Verlag, pages 201-202, 1983.
2. Donald Knuth,
The Art of Computer Programming,
Volume 2: Seminumerical Algorithms,

### Examples:

• normal_02_01000.txt, is the file created in response to the command
"normal_dataset 2 1000 123456789 1 2 1 0 0 3".

### List of Routines:

• MAIN is the main program for NORMAL_DATASET.
• GET_UNIT returns a free FORTRAN unit number.
• MULTINORMAL_SAMPLE samples a multivariate normal distribution.
• R8_UNIFORM_01 returns a unit pseudorandom R8.
• R8MAT_PRINT prints an R8MAT.
• R8MAT_PRINT_SOME prints some of an R8MAT.
• R8MAT_WRITE writes an R8MAT file.
• R8PO_FA factors an R8PO matrix.
• R8VEC_NORMAL_01 returns a unit pseudonormal R8VEC.
• R8VEC_PRINT prints an R8VEC.
• R8VEC_UNIFORM_01 returns a unit pseudorandom R8VEC.
• S_TO_I4 reads an integer value from a string.
• TIMESTAMP prints the current YMDHMS date as a time stamp.

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

Last revised on 08 December 2009.