@rwish |

Wishart random draw.

Syntax: @rwish(S, n)

@rwishc(S, n)

@rwishi(S, n)

@rwishic(S, n)

X: (optional) sym,

S: sym, matrix,

n: number,

Return: sym

Draw a random symmetric Wishart matrix using the density function.

The Wishart density is given by

where and are symmetric matrices, and .

There are four different forms of the function, corresponding to different ways of specifying . The forms are distinguished by different suffixes that are applied to the base “@rwish” command and how they change the interpretation of the S matrix argument:

@rwish | “” | Supply . |

@rwishc | “c” | Supply the Cholesky decomposition of . This form is more efficient when performing multiple draws from the same distribution (compute the Cholesky once, but sample many times). |

@rwishi | “i” | Supply . This form is more efficient than explicitly inverting to supply . |

@rwishic | “ic” | Supply the Cholesky decomposition of . This form combines the efficiencies of the Cholesky and inverse forms. |

is generally thought of as the accumulated scatter matrix of n random draws from , i.e., ,

,

though the mathematical definition has been extended to cover real-valued n.

Note that if is a Wishart random variable, then follows an inverse Wishart distribution:

Examples

= @rwish(@identity(3), 5)

returns a random draw from the distribution.

Cross-references