The RANDMVT function is part of the IMLMLIB library. The RANDMVT function returns an matrix that contains random draws from the Student’s distribution with DF degrees of freedom, mean vector Mean, and covariance matrix Cov.
The inputs are as follows:
is the number of desired observations sampled from the multivariate Student’s distribution.
is a scalar value that represents the degrees of freedom for the distribution.
is a vector of means.
is a symmetric positive definite variance-covariance matrix.
If follows a multivariate distribution with degrees of freedom, mean vector , and variance-covariance matrix , then
the probability density function for is
if , the probability density function reduces to a univariate Student’s distribution.
the expected value of is .
the covariance of and is when .
The following example generates 1,000 samples from a two-dimensional distribution with 7 degrees of freedom, mean vector , and covariance matrix S
. Each row of the returned matrix x
is a row vector sampled from the distribution. The example computes the sample mean and covariance and compares them with the expected values.
call randseed(1); N = 1000; DF = 4; Mean = {1 2}; S = {1 1, 1 5}; x = RandMVT( N, DF, Mean, S ); SampleMean = x[:,]; y = x - SampleMean; SampleCov = y`*y / (n-1); Cov = (DF/(DF-2)) * S; print SampleMean Mean, SampleCov Cov;
Figure 24.301: Estimated Mean and Covariance Matrix
SampleMean | Mean | ||
---|---|---|---|
1.0109905 | 1.9372765 | 1 | 2 |
SampleCov | Cov | ||
---|---|---|---|
1.9556572 | 2.2581732 | 2 | 2 |
2.2581732 | 10.437216 | 2 | 10 |
In the preceding example, the columns (marginals) of x
do not follow univariate distributions. If you want a sample whose marginals are univariate , then you need to scale each column of the output matrix:
x = RandMVT( N, DF, Mean, S ); StdX = x / sqrt(T(vecdiag(S))); /* StdX columns are univariate t */
Equivalently, you can generate samples whose marginals are univariate by passing in a correlation matrix instead of a general covariance matrix.
For further details about sampling from the multivariate distribution, see Kotz and Nadarajah (2004).