Language Reference

RANDMVT Function

RANDMVT (N, DF, Mean, Cov ) ;

This function is supported by the IML procedure and the iml action.

The RANDMVT function is part of the IMLMLIB library. The RANDMVT function returns an upper N times p matrix that contains N random draws from the Student’s t distribution with DF degrees of freedom, mean vector Mean, and covariance matrix Cov.

The inputs are as follows:

N

is the number of desired observations sampled from the multivariate Student’s t distribution.

DF

is a scalar value that represents the degrees of freedom for the t distribution.

Mean

is a 1 times p vector of means.

Cov

is a p times p symmetric positive definite variance-covariance matrix.

If X follows a multivariate t distribution with nu degrees of freedom, mean vector mu, and variance-covariance matrix normal upper Sigma, then

  • the probability density function for x is

    f left-parenthesis x semicolon nu comma mu comma normal upper Sigma right-parenthesis equals StartFraction normal upper Gamma left-parenthesis left-parenthesis nu plus p right-parenthesis slash 2 right-parenthesis Over StartAbsoluteValue normal upper Sigma EndAbsoluteValue Superscript 1 slash 2 Baseline left-parenthesis pi nu right-parenthesis Superscript p slash 2 Baseline normal upper Gamma left-parenthesis nu slash 2 right-parenthesis EndFraction left-parenthesis 1 plus StartFraction left-parenthesis x minus mu right-parenthesis normal upper Sigma Superscript negative 1 Baseline left-parenthesis x minus mu right-parenthesis Superscript upper T Baseline Over nu EndFraction right-parenthesis Superscript minus left-parenthesis nu plus p right-parenthesis slash 2
  • if p equals 1, the probability density function reduces to a univariate Student’s t distribution.

  • the expected value of upper X Subscript i is mu Subscript i.

  • the covariance of upper X Subscript i and upper X Subscript j is StartFraction nu Over nu minus 2 EndFraction normal upper Sigma Subscript i j when nu greater-than 2.

The following example generates 1,000 samples from a two-dimensional t distribution with 7 degrees of freedom, mean vector (1, 2), and covariance matrix S. Each row of the returned matrix x is a row vector sampled from the t 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};
Cov = DF/(DF-2) * S;  /* population covariance */
x = RandMVT( N, DF, Mean, S );
SampleMean = mean(x);
SampleCov = cov(x);
print SampleMean Mean, SampleCov Cov;

Figure 343: Estimated Mean and Covariance Matrix

SampleMean Mean 
1.01099051.937276512

SampleCov Cov 
1.95565722.258173222
2.258173210.437216210


In the preceding example, the columns (marginals) of x do not follow univariate t distributions. If you want a sample whose marginals are univariate t, 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 t by passing in a correlation matrix instead of a general covariance matrix.

For further details about sampling from the multivariate t distribution, see Kotz and Nadarajah (2004).

Last updated: May 07, 2026