normal_dataset
normal_dataset,
an Octave code 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 symmetric positive definite (SPD)
matrix called the variance-covariance matrix.
To create X, an MxN matrix containing N samples from this distribution,
it is only necessary to
-
create an MxN vector Y, each of whose elements is a sample of the
1-dimensional normal distribution with mean 0 and variance 1;
-
determine the upper triangular Cholesky factor R of the matrix A, so that
A = R' * R;
-
compute X = MU + R' * Y.
Usage:
r = 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.
-
r is the computed m by n sequence.
The data is written to the file normal_m_n.txt.
Licensing:
The information on this web page is distributed under the MIT license.
Languages:
normal_dataset is available in
a C++ version and
a Fortran90 version and
a MATLAB version and
an Octave version and
a Python version.
Related Data and Programs:
normal_dataset_test
normal,
an Octave code which
computes normally distributed pseudorandom values.
Reference:
-
Paul Bratley, Bennett Fox, Linus Schrage,
A Guide to Simulation,
Springer Verlag, pages 201-202, 1983.
-
Donald Knuth,
The Art of Computer Programming,
Volume 2: Seminumerical Algorithms,
Addison Wesley, 1969.
Source Code:
Last revised on 15 May 2024.