Module Library


generates a random sample from a Wishart distribution


The inputs are as follows:

is the number of desired observations sampled from the distribution.

is a scalar value representing the degrees of freedom, {df} \geq p.
is a p x p symmetric positive definite matrix.

The RANDWISHART function returns an n x (p x p) matrix containing n random draws from the Wishart distribution with DF degrees of freedom. Each row of the returned matrix represents a p x p matrix.

The Wishart distribution is a multivariate generalization of the gamma distribution. (Note, however, that Kotz, Balakrishnan, and Johnson 2000 suggest that the term "multivariate gamma distribution" should be restricted to those distributions for which the marginal distributions are univariate gamma. This is not the case with the Wishart distribution.) A Wishart distribution is a probability distribution for nonnegative definite matrix-valued random variables. These distributions are often used to estimate covariance matrices.

If a p x p nonnegative definite matrix x follows a Wishart distribution with parameters \nu degrees of freedom and a p x p symmetric positive definite matrix \sigma, then

The following example generates 1000 samples from a Wishart distribution with 7 degrees of freedom and 2x 2 matrix parameter S. Each row of the returned matrix x represents a 2x 2 nonnegative definite matrix. (You can reshape the ith row of x with the SHAPE function.) The example then computes the sample mean and compares them with the expected value. Here are the code and the output:

    call randseed(1); 
    DF = 7; 
    S = {1 1, 1 5}; 
    x = RandWishart( N, DF, S ); 
    ExpectedValue = DF * S; 
    SampleMean = shape( x[:,], 2, 2); 
    print SampleMean ExpectedValue; 
                      SampleMean            ExpectedValue 
                 7.0518633 14.103727         7        14 
                 14.103727 28.207453        14        28

For further details about sampling from the Wishart distribution, see Johnson (1987, pp. 203 - 204).

Previous Page | Next Page | Top of Page