use of beast.core.parameter.IntegerParameter in project bacter by tgvaughan.
the class SkylinePopulationFunctionTest method test1.
@Test
public void test1() throws Exception {
SkylinePopulationFunction skyline = new SkylinePopulationFunction();
skyline.initByName("acg", acg, "popSizes", new RealParameter("5.0 1.0 5.0 1.0"), "groupSizes", new IntegerParameter("0 0 0 0"));
for (double t = 0.0; t < 10; t += 0.01) assertTrue(Math.abs(t - skyline.getInverseIntensity(skyline.getIntensity(t))) < 1e-14);
}
use of beast.core.parameter.IntegerParameter in project bacter by tgvaughan.
the class SkylinePopulationFunction method initAndValidate.
@Override
public void initAndValidate() {
super.initAndValidate();
acg = acgInput.get();
popSizes = popSizesInput.get();
groupSizes = groupSizesInput.get();
// Initialize groupSizes to something sensible.
if (initGroupSizesInput.get()) {
int nChangePoints;
if (nGridPointsInput.get() == null)
nChangePoints = acg.getInternalNodeCount();
else
nChangePoints = nGridPointsInput.get();
Integer[] values = new Integer[popSizes.getDimension()];
int cumulant = 0;
for (int i = 0; i < values.length; i++) {
values[i] = nChangePoints / values.length;
cumulant += values[i];
}
values[values.length - 1] += nChangePoints - cumulant;
IntegerParameter newParam = new IntegerParameter(values);
newParam.setBounds(1, Integer.MAX_VALUE);
groupSizes.assignFromWithoutID(newParam);
}
groupBoundaries = new double[groupSizes.getDimension()];
intensities = new double[groupSizes.getDimension()];
dirty = true;
}
use of beast.core.parameter.IntegerParameter in project bacter by tgvaughan.
the class SkylinePopulationFunctionTest method test5.
@Test
public void test5() throws Exception {
SkylinePopulationFunction skyline = new SkylinePopulationFunction();
skyline.initByName("acg", acg, "popSizes", new RealParameter("1.0 1.0 5.0 1.0"), "groupSizes", new IntegerParameter("0"), "nGridPoints", 5, "piecewiseLinear", true);
for (double t = 0.0; t < 10; t += 0.01) assertTrue(Math.abs(t - skyline.getInverseIntensity(skyline.getIntensity(t))) < 1e-14);
}
use of beast.core.parameter.IntegerParameter in project bacter by tgvaughan.
the class SkylinePopulationFunctionTest method test6.
@Test
public void test6() throws Exception {
SkylinePopulationFunction skyline = new SkylinePopulationFunction();
skyline.initByName("acg", acg, "popSizes", new RealParameter("1.0 1.0 5.0 1.0"), "groupSizes", new IntegerParameter("0"), "nGridPoints", 5, "piecewiseLinear", true);
for (CFEventList.Event cfEvent : acg.getCFEvents()) {
double t = cfEvent.getHeight();
assertTrue(Math.abs(t - skyline.getInverseIntensity(skyline.getIntensity(t))) < 1e-14);
}
}
use of beast.core.parameter.IntegerParameter in project bacter by tgvaughan.
the class PiecewisePopulationFunction method main.
/**
* Main method for testing.
*
* @param args command line arguments (unused)
*/
public static void main(String[] args) throws Exception {
String acgString = "[&15,0,1.3905355989030808,31,770,1.597708055397074] " + "[&30,931,2.4351280458424904,36,2486,3.78055549386568] " + "[&15,941,2.0439957300083322,38,2364,6.911056700367016] " + "[&36,1091,4.285505683622974,38,2589,9.867725913197855] " + "((((10:0.5385300170206817,(17:0.116794353049212," + "((3:0.039229346597297564,12:0.039229346597297564)23:0.04582913870888949," + "13:0.08505848530618705)24:0.03173586774302495)26:0.4217356639714697)28:1.8114199763246093," + "((8:0.10883006062265468,2:0.10883006062265468)25:0.556428062025291," + "(6:0.5393311342677402,11:0.5393311342677402)29:0.12592698838020555)31:1.6846918706973453)34:1.4536824928125807," + "(1:0.47184545557390367,14:0.47184545557390367)27:3.331787030583968)37:2.9704369411362554," + "(((15:2.0624287390593707,((16:0.01825347077733299,19:0.01825347077733299)21:0.7668749128372041," + "(7:0.008018731329538273,9:0.008018731329538273)20:0.7771096522849988)32:1.2773003554448337)33:0.7487092404613747," + "4:2.8111379795207454)35:0.1331794525400949,((0:0.0243537216663141," + "5:0.0243537216663141)22:0.5681537100482162,18:0.5925074317145304)30:2.35181000034631)36:3.829751995233287)38:0.0";
ConversionGraph acg = new ConversionGraph();
acg.initByName("siteCount", 10000, "fromString", acgString);
PiecewisePopulationFunction skyline = new PiecewisePopulationFunction();
skyline.initByName("acg", acg, "popSizes", new RealParameter("1.0 1.0 5.0 1.0 2.0"), "groupSizes", new IntegerParameter("0"), "piecewiseLinear", true);
try (PrintStream ps = new PrintStream("out.txt")) {
ps.println("t N intensity intensityInv");
double t = 0.0;
while (t < 10) {
ps.format("%g %g %g %g\n", t, skyline.getPopSize(t), skyline.getIntensity(t), skyline.getInverseIntensity(skyline.getIntensity(t)));
t += 0.001;
}
ps.close();
}
}
Aggregations