Main Content

mvtrnd

Multivariatetrandom numbers

Syntax

R = mvtrnd(C,df,cases)
R = mvtrnd(C,df)

Description

R = mvtrnd(C,df,cases)returns a matrix of random numbers chosen from the multivariatetdistribution, whereCis a correlation matrix.dfis the degrees of freedom and is either a scalar or is a vector withcaseselements. Ifpis the number of columns inC, then the outputRhascasesrows andpcolumns.

Lettrepresent a row ofR. Then the distribution oftis that of a vector having a multivariate normal distribution with mean 0, variance 1, and covariance matrixC, divided by an independent chi-square random value havingdfdegrees of freedom. The rows ofRare independent.

Cmust be a square, symmetric and positive definite matrix. If its diagonal elements are not all 1 (that is, ifCis a covariance matrix rather than a correlation matrix),mvtrndrescalesCto transform it to a correlation matrix before generating the random numbers.

R = mvtrnd(C,df)returns a single random number from the multivariatetdistribution.

Examples

collapse all

Generate random numbers from a multivariatetdistribution with correlation parametersSIGMA = [1 0.8;0.8 1]and 3 degrees of freedom.

rngdefault;% For reproducibilitySIGMA = [1 0.8;0.8 1]; R = mvtrnd(SIGMA,3,100);

Plot the random numbers.

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

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

版本历史

Introduced before R2006a