Last change
on this file since 177 was
37,
checked in by (none), 15 years ago
|
Added original make3d
|
-
Property svn:executable set to
*
|
File size:
638 bytes
|
Line | |
---|
1 | function cholX = randwishart(a,d)
|
---|
2 | %RANDWISHART Sample from Wishart distribution.
|
---|
3 | %
|
---|
4 | % cholX = RANDWISHART(A,D) returns a DxD upper triangular matrix such that
|
---|
5 | % cholX'*cholX is a sample from a Wishart distribution with shape parameter
|
---|
6 | % A and unit scale.
|
---|
7 | %
|
---|
8 | % The probability density function has the form:
|
---|
9 | % p(X) = |X|^(a-(d+1)/2)*exp(-tr(X))/Gamma_d(a)
|
---|
10 | % where Gamma_d is the multivariate Gamma function.
|
---|
11 |
|
---|
12 | % Written by Tom Minka
|
---|
13 | % (c) Microsoft Corporation. All rights reserved.
|
---|
14 |
|
---|
15 | sqrth = 0.70710678118655; % sqrt(0.5)
|
---|
16 | cholX = triu(randn(d,d))*sqrth;
|
---|
17 | i = 0:(d-1);
|
---|
18 | cholX(finddiag(cholX)) = sqrt(randgamma(a - i*0.5));
|
---|
Note: See
TracBrowser
for help on using the repository browser.