public final double calculateIntervalLikelihood(DemographicFunction demoFunction,double width,double timeOfPrevCoal,int lineageCount,int type){
  double timeOfThisCoal=width + timeOfPrevCoal;
  double intervalArea=demoFunction.getIntegral(timeOfPrevCoal,timeOfThisCoal);
  double like=0;
switch (type) {
case COALESCENT:
    like=-Math.log(demoFunction.getDemographic(timeOfThisCoal)) - (Binomial.choose2(lineageCount) * intervalArea);
  break;
case NEW_SAMPLE:
like=-(Binomial.choose2(lineageCount) * intervalArea);
break;
}
return like;
}

public final double calculateIntervalLikelihood ( DemographicFunction demoFunction , double width , double timeOfPrevCoal , int lineageCount , int type ) { double timeOfThisCoal = width + timeOfPrevCoal ; double intervalArea = demoFunction . getIntegral ( timeOfPrevCoal , timeOfThisCoal ) ; double like = 0 ; switch ( type ) { case COALESCENT : like = - Math . log ( demoFunction . getDemographic ( timeOfThisCoal ) ) - ( Binomial . choose2 ( lineageCount ) * intervalArea ) ; break ; case NEW_SAMPLE : like = - ( Binomial . choose2 ( lineageCount ) * intervalArea ) ; break ; } return like ; }
returns the likelihood of a given interval , coalescent or otherwise .
