Skip to content

Commit

Permalink
latency log lik
Browse files Browse the repository at this point in the history
  • Loading branch information
brj1 committed Feb 17, 2023
1 parent e8f41ad commit 20d4587
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Binary file removed dist/BBD.addon.zip
Binary file not shown.
13 changes: 7 additions & 6 deletions src/bbd/distributions/LatencyPrior.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void initAndValidate() {

@Override
public double calculateLogP() {
if (!initialised) {
if (!initialised) {
initialise();
}

Expand All @@ -88,17 +88,18 @@ public double calculateLogP() {
int k = 0;

final double tMRCA = tree.getRoot().getDate();
final double rate = reactivationRate - latencyRate;
final double rate = reactivationRate - latencyRate;
final double logRate = Math.log(rate);
final double tMRCAFactor = Math.log(rate * tMRCA);

for (final int i : taxonIndex) {
double date = tree.getNode(i).getDate();

if (date > tMRCA && date < oriDate[k]) {
// likelihood of going latent at `date` given sampling date
logP += Math.exp(rate * date) *
rate /
(Math.exp(rate * oriDate[k]) -
Math.exp(rate * tMRCA));
logP += rate * date +
logRate -
Math.log(Math.exp(rate * oriDate[k]) - tMRCAFactor);
} else {
// not in range
return Double.NEGATIVE_INFINITY;
Expand Down

0 comments on commit 20d4587

Please sign in to comment.