Main Content

lhsnorm

Latin hypercube sample from multivariate normal distribution

Description

X = lhsnorm(mu,sigma,n) returns a numeric matrix X containing a Latin hypercube sample of size n from a multivariate normal distribution with mean vector mu and covariance matrix sigma. The size of X is n-by-d, where d is the size of mu. X is similar to a random sample generated from the multivariate normal distribution (see mvnrnd), but lhsnorm adjusts the marginal distribution of each column so that its sample marginal distribution is close to its theoretical normal distribution.

example

X = lhsnorm(mu,sigma,n,Smooth) additionally sets the type of sample smoothing.

[X,Z] = lhsnorm(___) also returns the original multivariate normal sample Z, using any of the input argument combinations in the previous syntaxes. lhsnorm generates z with mvnrnd before it adjusts the marginal distributions to obtain X.

Examples

collapse all

Define the mean vector and covariance matrix of a two-dimensional normal distribution.

mu = [0 1];
sigma = [1 0.5; 0.5 1];

Verify that the covariance matrix is symmetric and positive semi-definite.

issymmetric(sigma)
ans = logical
   1

eigenvalues = eig(sigma);
all(eigenvalues >= 0)
ans = logical
   1

The eigenvalues of sigma are all nonnegative, indicating that the covariance matrix is positive semi-definite.

Create a Latin hypercube sample of size 100 from the two-dimensional normal distribution.

X = lhsnorm(mu,sigma,100);

Plot a histogram of the values in the first column of X.

hist(X(:,1))

Figure contains an axes object. The axes object contains an object of type patch.

Input Arguments

collapse all

Mean vector of a multivariate normal distribution, specified as a 1-by-d numeric vector where d is the dimension of the multivariate normal distribution, or as a numeric scalar.

Data Types: single | double

Covariance matrix of a multivariate normal distribution, specified as a d-by-d symmetric, positive semi-definite matrix, where d is the dimension of the multivariate normal distribution, or as a numeric scalar. If you specify sigma as a numeric scalar, it represents the variance of a one-dimensional normal distribution.

Data Types: single | double

Number of returned samples in X, specified as a nonnegative integer.

Data Types: single | double

Flag for sample smoothing, specified as "on" or "off".

  • If Smooth is "off", then each column of X has points equally spaced on the probability scale. Therefore, each column is a permutation of the values G(0.5/n), G(1.5/n), ..., G(1-0.5/n), where G is the inverse normal cumulative distribution for that column's marginal distribution.

  • If Smooth is "on" (the default), then each column of X has points uniformly distributed on the probability scale. Therefore, lhsnorm samples G at n uniformly distributed random values between 0 and 1.

Data Types: char | string

Output Arguments

collapse all

Latin hypercube sample from a multivariate normal distribution, returned as an n-by-d numeric matrix, where d is the size of mu. X is similar to a random sample generated from the multivariate normal distribution (see mvnrnd), but lhsnorm adjusts the marginal distribution of each column so that its sample marginal distribution is close to its theoretical normal distribution.

Original multivariate normal sample, returned as an n-by-d numeric matrix, where d is the size of mu. lhsnorm calls mvnrnd to create Z before it adjusts the marginal distributions to obtain X.

Tips

  • lhsnorm requires the covariance matrix sigma to be symmetric. If sigma has only minor asymmetry, you can use (sigma + sigma')/2 to resolve the asymmetry.

References

[1] Stein, M. “Large Sample Properties of Simulations Using Latin Hypercube Sampling.” Technometrics 29, no. 2 (May 1987): 143–151.

Version History

Introduced before R2006a