Search in sources :

Example 16 with Statistic

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;
}
Also used : RatioStatistic(dr.inference.model.RatioStatistic) Statistic(dr.inference.model.Statistic) RatioStatistic(dr.inference.model.RatioStatistic)

Example 17 with Statistic

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());
    }
}
Also used : Statistic(dr.inference.model.Statistic) ParametricDistributionModel(dr.inference.distribution.ParametricDistributionModel) MixedDistributionLikelihood(dr.inference.distribution.MixedDistributionLikelihood)

Example 18 with Statistic

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;
}
Also used : DifferenceStatistic(dr.inference.model.DifferenceStatistic) Statistic(dr.inference.model.Statistic) DifferenceStatistic(dr.inference.model.DifferenceStatistic)

Example 19 with Statistic

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;
}
Also used : ExpressionStatistic(dr.inference.model.ExpressionStatistic) ExpressionStatistic(dr.inference.model.ExpressionStatistic) Statistic(dr.inference.model.Statistic)

Example 20 with Statistic

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));
    }
}
Also used : DateParser(dr.evoxml.DateParser) Taxa(dr.evolution.util.Taxa) AttributeParser(dr.xml.AttributeParser) Statistic(dr.inference.model.Statistic) TaxaParser(dr.evoxml.TaxaParser) FileReader(java.io.FileReader) TaxonParser(dr.evoxml.TaxonParser) XMLParser(dr.xml.XMLParser) File(java.io.File)

Aggregations

Statistic (dr.inference.model.Statistic)21 Taxa (dr.evolution.util.Taxa)2 DistributionLikelihood (dr.inference.distribution.DistributionLikelihood)2 ParametricDistributionModel (dr.inference.distribution.ParametricDistributionModel)2 SumStatistic (dr.inference.model.SumStatistic)2 Tree (dr.evolution.tree.Tree)1 Taxon (dr.evolution.util.Taxon)1 TaxonList (dr.evolution.util.TaxonList)1 CalibrationPoints (dr.evomodel.speciation.CalibrationPoints)1 SpeciationLikelihood (dr.evomodel.speciation.SpeciationLikelihood)1 SpeciationModel (dr.evomodel.speciation.SpeciationModel)1 DateParser (dr.evoxml.DateParser)1 TaxaParser (dr.evoxml.TaxaParser)1 TaxonParser (dr.evoxml.TaxonParser)1 EmpiricalDistributionLikelihood (dr.inference.distribution.EmpiricalDistributionLikelihood)1 MixedDistributionLikelihood (dr.inference.distribution.MixedDistributionLikelihood)1 SplineInterpolatedLikelihood (dr.inference.distribution.SplineInterpolatedLikelihood)1 Bounds (dr.inference.model.Bounds)1 CoulombPrior (dr.inference.model.CoulombPrior)1 DifferenceStatistic (dr.inference.model.DifferenceStatistic)1