source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/lightspeed/randwishart.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

  • Property svn:executable set to *
File size: 638 bytes
Line 
1function 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
15sqrth = 0.70710678118655;  % sqrt(0.5)
16cholX = triu(randn(d,d))*sqrth;
17i = 0:(d-1);
18cholX(finddiag(cholX)) = sqrt(randgamma(a - i*0.5));
Note: See TracBrowser for help on using the repository browser.