use of beast.core.parameter.RealParameter in project beast2 by CompEvol.
the class UnorderedAlignmentsTest method getTree.
public static Tree getTree(TaxonSet taxa) throws Exception {
Tree tree = new RandomTree();
TraitSet dates = getDates(taxa);
ConstantPopulation constant = new ConstantPopulation();
constant.initByName("popSize", new RealParameter("5.0"));
tree.initByName("taxonset", taxa, "populationModel", constant, "trait", dates);
return tree;
}
use of beast.core.parameter.RealParameter in project beast2 by CompEvol.
the class DeltaExchangeOperatorTest method testKeepsSum.
@Test
public void testKeepsSum() {
DeltaExchangeOperator operator = new DeltaExchangeOperator();
RealParameter parameter = new RealParameter(new Double[] { 1., 1., 1., 1. });
register(operator, "parameter", parameter);
for (int i = 0; i < 100; ++i) {
operator.proposal();
}
double i = 0;
for (Double p : parameter.getValues()) {
i += p;
}
assertEquals("The DeltaExchangeOperator should not change the sum of a parameter", i, 4, 0.00001);
}
use of beast.core.parameter.RealParameter in project beast2 by CompEvol.
the class DeltaExchangeOperatorTest method testCanOperate.
@Test
public void testCanOperate() {
// Test whether a validly initialised operator may make proposals
State state = new State();
RealParameter parameter = new RealParameter(new Double[] { 1., 1., 1., 1. });
state.initByName("stateNode", parameter);
state.initialise();
DeltaExchangeOperator d = new DeltaExchangeOperator();
// proposals
try {
d.initByName("parameter", parameter);
} catch (RuntimeException e) {
return;
}
d.proposal();
}
use of beast.core.parameter.RealParameter in project beast2 by CompEvol.
the class DeltaExchangeOperatorTest method testKeepsWeightedSum.
@Test
public void testKeepsWeightedSum() {
RealParameter parameter = new RealParameter(new Double[] { 1., 1., 1., 1. });
register(new DeltaExchangeOperator(), "weightvector", new IntegerParameter(new Integer[] { 0, 1, 2, 1 }), "parameter", parameter);
Double[] p = parameter.getValues();
assertEquals("The DeltaExchangeOperator should not change the sum of a parameter", 0 * p[1] + 1 * p[1] + 2 * p[2] + 1 * p[3], 4, 0.00001);
}
use of beast.core.parameter.RealParameter in project beast2 by CompEvol.
the class GTRTest method testGTR.
public void testGTR() throws Exception {
for (Instance test : all) {
RealParameter f = new RealParameter(test.getPi());
Frequencies freqs = new Frequencies();
freqs.initByName("frequencies", f, "estimate", false);
GTR gtr = new GTR();
Double[] rates = test.getRates();
gtr.initByName("rateAC", new RealParameter(rates[0] + ""), "rateAG", new RealParameter(rates[1] + ""), "rateAT", new RealParameter(rates[2] + ""), "rateCG", new RealParameter(rates[3] + ""), "rateCT", new RealParameter(rates[4] + ""), "rateGT", new RealParameter(rates[5] + ""), "frequencies", freqs);
double distance = test.getDistance();
double[] mat = new double[4 * 4];
gtr.getTransitionProbabilities(null, distance, 0, 1, mat);
final double[] result = test.getExpectedResult();
for (int k = 0; k < mat.length; ++k) {
assertEquals(mat[k], result[k], 1e-10);
System.out.println(k + " : " + (mat[k] - result[k]));
}
}
}
Aggregations