use of dr.inference.model.Statistic in project beast-mcmc by beast-dev.
the class RatioStatisticParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Statistic numerator = (Statistic) xo.getChild(0);
Statistic denominator = (Statistic) xo.getChild(1);
RatioStatistic ratioStatistic;
try {
ratioStatistic = new RatioStatistic(RATIO_STATISTIC, numerator, denominator);
} catch (IllegalArgumentException iae) {
throw new XMLParseException("Error parsing " + getParserName() + " the numerator and denominator statistics " + "should be of the same dimension or of dimension 1");
}
return ratioStatistic;
}
use of dr.inference.model.Statistic in project beast-mcmc by beast-dev.
the class MixedDistributionLikelihoodParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
XMLObject cxo0 = xo.getChild(DISTRIBUTION0);
ParametricDistributionModel model0 = (ParametricDistributionModel) cxo0.getChild(ParametricDistributionModel.class);
XMLObject cxo1 = xo.getChild(DISTRIBUTION1);
ParametricDistributionModel model1 = (ParametricDistributionModel) cxo1.getChild(ParametricDistributionModel.class);
Statistic data = (Statistic) ((XMLObject) xo.getChild(DATA)).getChild(Statistic.class);
Statistic indicators = (Statistic) ((XMLObject) xo.getChild(INDICATORS)).getChild(Statistic.class);
ParametricDistributionModel[] models = { model0, model1 };
try {
return new MixedDistributionLikelihood(models, data, indicators);
} catch (Exception e) {
throw new XMLParseException(e.getMessage());
}
}
use of dr.inference.model.Statistic in project beast-mcmc by beast-dev.
the class DifferenceStatisticParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
boolean absolute = xo.getAttribute(ABSOLUTE, false);
Statistic term1 = (Statistic) xo.getChild(0);
Statistic term2 = (Statistic) xo.getChild(1);
DifferenceStatistic differenceStatistic;
try {
differenceStatistic = new DifferenceStatistic(DIFFERENCE_STATISTIC, term1, term2, absolute);
} catch (IllegalArgumentException iae) {
throw new XMLParseException("Error parsing " + getParserName() + " the left and right statistics " + "should be of the same dimension or of dimension 1");
}
return differenceStatistic;
}
use of dr.inference.model.Statistic in project beast-mcmc by beast-dev.
the class ExpressionStatisticParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
XMLObject cxo = xo.getChild(EXPRESSION);
String expression = cxo.getStringChild(0);
ExpressionStatistic expStatistic = new ExpressionStatistic(EXPRESSION_STATISTIC, expression);
System.out.println("Expression: " + expression);
System.out.println(" variables:");
cxo = xo.getChild(VARIABLES);
for (int i = 0; i < cxo.getChildCount(); i++) {
Object child = cxo.getChild(i);
if (child instanceof Statistic) {
Statistic stat = (Statistic) child;
expStatistic.addStatistic(stat);
System.out.println(" " + stat.getStatisticName() + "=" + stat.getStatisticValue(0));
} else {
throw new XMLParseException("Unknown element found in " + getParserName() + " element:" + child);
}
}
System.out.println(" value: " + expStatistic.getStatisticValue(0));
return expStatistic;
}
use of dr.inference.model.Statistic in project beast-mcmc by beast-dev.
the class GreatCircleDistances method main.
public static void main(String[] args) throws ParserConfigurationException, IOException, SAXException, XMLParseException {
XMLParser parser = new XMLParser(true, true);
parser.addXMLObjectParser(new TaxonParser());
parser.addXMLObjectParser(new TaxaParser());
parser.addXMLObjectParser(new AttributeParser());
parser.addXMLObjectParser(new DateParser());
parser.parse(new FileReader(new File(args[0])), true);
Taxa taxa = (Taxa) parser.getRoot().getChild(0);
System.out.println("Found " + taxa.getTaxonCount() + " taxa");
GreatCircleDistances distances = new GreatCircleDistances(taxa, "location");
Statistic statistic = distances.getDistanceStatistic(true);
for (int i = 0; i < statistic.getDimension(); i++) {
System.out.println(statistic.getStatisticValue(i));
}
}
Aggregations