Skip to content

Commit

Permalink
reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
xji3 committed Nov 15, 2024
1 parent 04e75f9 commit ef8fbc5
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import dr.math.NumericalDerivative;

/**
* @author Alexander Fisher
* @author Alexander Fisher
*/

public class ApproximateTreeDataLikelihood {
Expand All @@ -49,28 +49,29 @@ public class ApproximateTreeDataLikelihood {

// begin parser stuff
public static final String APPROXIMATE_LIKELIHOOD = "approximateTreeDataLikelihood";

// end parser stuff
public ApproximateTreeDataLikelihood(MaximizerWrtParameter maximizer) {
public ApproximateTreeDataLikelihood(MaximizerWrtParameter maximizer) {

this.maximizer = maximizer;
this.parameter = maximizer.getGradient().getParameter();
this.numericalHessian = new double[parameter.getDimension()];
// todo: get Numerical Hessian.
this.maximizer = maximizer;
this.parameter = maximizer.getGradient().getParameter();
this.numericalHessian = new double[parameter.getDimension()];
// todo: get Numerical Hessian.
// NumericalDerivative.getNumericalHessian();
updateParameterMAP();
updateMarginalLikelihood();

}

private void updateMarginalLikelihood() {
double diagonalDeterminant = 1;
for(int i = 0; i < parameter.getDimension(); i++) {
diagonalDeterminant *= numericalHessian[i];
}
double diagonalDeterminant = 1;
for (int i = 0; i < parameter.getDimension(); i++) {
diagonalDeterminant *= numericalHessian[i];
}
// 2pi^{-k/2} * det(Sigma)^{-1/2} * likelihood(map) * prior(map)
// todo: eval posterior(map)
// todo: log likelihood
this.marginalLikelihood = 2 / (Math.pow(Math.PI, -1 * parameter.getDimension() / 2) * Math.sqrt(diagonalDeterminant));
this.marginalLikelihood = 2 / (Math.pow(Math.PI, -1 * parameter.getDimension() / 2) * Math.sqrt(diagonalDeterminant));
}

private void updateParameterMAP() {
Expand All @@ -80,6 +81,7 @@ private void updateParameterMAP() {
public double getMarginalLikelihood() {
return marginalLikelihood;
}

public double[] getParameterMAP() {
return parameterMAP;
}
Expand Down

0 comments on commit ef8fbc5

Please sign in to comment.