Skip to content

Commit

Permalink
Merge branch 'hmc-clock' of https://github.com/beast-dev/beast-mcmc i…
Browse files Browse the repository at this point in the history
…nto hmc-clock
  • Loading branch information
xji3 committed Nov 19, 2024
2 parents e6e6b41 + faf1ae2 commit 2ab57d5
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public ApproximateTreeDataLikelihood(MaximizerWrtParameter maximizer) {
this.likelihood = maximizer.getLikelihood();
final GradientWrtParameterProvider gradient = maximizer.getGradient();
this.parameter = gradient.getParameter();
this.marginalLikelihoodConst = Math.log(2) - parameter.getDimension() / 2 *Math.log(Math.PI);
this.marginalLikelihoodConst = (parameter.getDimension() - 1) * Math.log(2 * Math.PI);
// todo: get Numerical Hessian.
if (isGradientProvidingHessian(gradient)) {
this.hessianWrtParameterProvider = (HessianWrtParameterProvider) gradient;
Expand Down Expand Up @@ -161,14 +161,12 @@ public double[][] getHessianLogDensity() {

private void updateMarginalLikelihood() {
double[] diagonalHessian = hessianWrtParameterProvider.getDiagonalHessianLogDensity();
double diagonalDeterminant = 1;
double logDiagonalDeterminant = 0;
for (int i = 0; i < parameter.getDimension(); i++) {
diagonalDeterminant *= Math.abs(diagonalHessian[i]);
logDiagonalDeterminant += Math.log(Math.abs(diagonalHessian[i]));
}
// 2pi^{-k/2} * det(Sigma)^{-1/2} * likelihood(map) * prior(map)
// todo: eval posterior(map)
// todo: log likelihood
this.marginalLikelihood = marginalLikelihoodConst + 0.5 * Math.log(diagonalDeterminant) + likelihood.getLogLikelihood();
this.marginalLikelihood = marginalLikelihoodConst + 0.5 * logDiagonalDeterminant + likelihood.getLogLikelihood();
likelihoodKnown = true;
}

Expand Down

0 comments on commit 2ab57d5

Please sign in to comment.