Main Content

mvtrnd

Multivariate t random numbers

Description

R = mvtrnd(C,nu) returns random numbers sampled from a multivariate t distribution with the correlation matrix C and nu degrees of freedom.

R = mvtrnd(C,nu,n) returns a matrix R of n random vectors selected from the same multivariate t distribution, with the correlation matrix C and nu degrees of freedom.

example

Examples

collapse all

Generate 100 random number vectors from a multivariate t distribution with the 2-by-2 correlation matrix C and 3 degrees of freedom.

rng(0,"twister");  % For reproducibility
C = [1 0.8;0.8 1];
R = mvtrnd(C,3,100);

Each row of R is a vector of random numbers selected from the multivariate t distribution.

Plot the random numbers.

figure;
plot(R(:,1),R(:,2),"+")

Figure contains an axes object. The axes contains a line object which displays its values using only markers.

Input Arguments

collapse all

Correlation matrix, specified as a square, symmetric, positive definite matrix. If the diagonal elements of C are not all 1 (that is, if C is a covariance matrix rather than a correlation matrix), then the mvtrnd function rescales C to transform it to a correlation matrix before generating the random numbers.

Data Types: single | double

Degrees of freedom of the multivariate t distribution, specified as a positive scalar or a 1-by-n vector of positive scalars if you specify n.

Data Types: single | double

Number of multivariate random number vectors, specified as a positive scalar integer. n specifies the number of rows in R.

Data Types: single | double

Output Arguments

collapse all

Multivariate random numbers, returned as an m-by-d numeric matrix, where m is the value of n (or 1, if you do not specify n), and d is the dimension of C.

The function generates each row of R as a vector that has a multivariate t distribution with mean 0, variance 1, and covariance matrix C, divided by an independent chi-square random value having nu degrees of freedom. The rows of R are independent.

Version History

Introduced before R2006a