Skip to content

Commit

Permalink
tweak logMvGamma
Browse files Browse the repository at this point in the history
  • Loading branch information
sth4nth committed Mar 11, 2017
1 parent 3294beb commit d389cfa
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions chapter02/logMvGamma.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function y = logMvGamma(x,d)
function y = logMvGamma(x, d)
% Compute logarithm multivariate Gamma function
% which is used in the probability density function of the Wishart and inverse Wishart distributions.
% Gamma_d(x) = pi^(d(d-1)/4) \prod_(j=1)^d Gamma(x+(1-j)/2)
Expand All @@ -9,8 +9,5 @@
% Output:
% y: m x n logarithm multivariate Gamma
% Written by Michael Chen ([email protected]).
sz = size(x);
x = reshape(x,1,prod(sz));
x = bsxfun(@plus,repmat(x,d,1),(1-(1:d)')/2);
y = d*(d-1)/4*log(pi)+sum(gammaln(x),1);
y = reshape(y,sz);
y = d*(d-1)/4*log(pi)+sum(gammaln(x(:)+(1-(1:d))/2),2);
y = reshape(y,size(x));

0 comments on commit d389cfa

Please sign in to comment.