use of dr.evolution.coalescent.ExponentialExponential in project beast-mcmc by beast-dev.
the class MultiEpochExponentialTest method testExponentialExponential.
public void testExponentialExponential() {
Units.Type units = Units.Type.YEARS;
ExponentialExponential ee = new ExponentialExponential(units);
ee.setN0(N0);
ee.setGrowthRate(rates[0]);
ee.setAncestralGrowthRate(rates[1]);
ee.setTransitionTime(transitionTimes[0]);
MultiEpochExponential mee = new MultiEpochExponential(units, 2);
mee.setN0(N0);
for (int i = 0; i < rates.length; ++i) {
mee.setGrowthRate(i, rates[i]);
}
for (int i = 0; i < transitionTimes.length; ++i) {
mee.setTransitionTime(i, transitionTimes[i]);
}
for (double time = 0; time < 20; time += 1.0) {
double eeDemo = ee.getDemographic(time);
double meeDemo = mee.getDemographic(time);
assertEquals(eeDemo, meeDemo, tolerance1);
}
double start = 0.0;
double finish = 1.0;
for (; finish < 20.0; finish += 1.0) {
double eeInt = ee.getIntegral(start, finish);
double meeIntN = mee.getNumericalIntegral(start, finish);
double meeIntA = mee.getAnalyticIntegral(start, finish);
// System.err.println(finish + ": " + eeInt + " " + meeIntN + " " + meeIntA);
assertEquals(eeInt, meeIntN, tolerance1);
assertEquals(meeIntN, meeIntA, tolerance2);
}
start = 0.5;
finish = 1.0;
for (; finish < 20.0; finish += 1.0) {
double eeInt = ee.getIntegral(start, finish);
double meeIntN = mee.getNumericalIntegral(start, finish);
double meeIntA = mee.getAnalyticIntegral(start, finish);
// System.err.println(finish + ": " + eeInt + " " + meeIntN + " " + meeIntA);
assertEquals(eeInt, meeIntN, tolerance1);
assertEquals(meeIntN, meeIntA, tolerance2);
}
start = 11.0;
finish = 11.0;
for (; finish < 20.0; finish += 1.0) {
double eeInt = ee.getIntegral(start, finish);
double meeIntN = mee.getNumericalIntegral(start, finish);
double meeIntA = mee.getAnalyticIntegral(start, finish);
// System.err.println(finish + ": " + eeInt + " " + meeIntN + " " + meeIntA);
assertEquals(eeInt, meeIntN, tolerance1);
assertEquals(meeIntN, meeIntA, tolerance2);
}
}
Aggregations