Search in sources :

Example 11 with Statistic

use of dr.inference.model.Statistic in project beast-mcmc by beast-dev.

the class SubStatisticParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    String name;
    if (xo.hasAttribute(Statistic.NAME) || xo.hasAttribute(dr.xml.XMLParser.ID))
        name = xo.getAttribute(Statistic.NAME, xo.getId());
    else
        name = "";
    final Statistic stat = (Statistic) xo.getChild(Statistic.class);
    final int[] values = xo.getIntegerArrayAttribute(DIMENSION);
    if (values.length == 0) {
        throw new XMLParseException("Must specify at least one dimension");
    }
    final int dim = stat.getDimension();
    for (int value : values) {
        if (value >= dim || value < 0) {
            throw new XMLParseException("Dimension " + value + " is not a valid dimension.");
        }
    }
    return new SubStatistic(name, values, stat);
}
Also used : SubStatistic(dr.inference.model.SubStatistic) SubStatistic(dr.inference.model.SubStatistic) Statistic(dr.inference.model.Statistic)

Example 12 with Statistic

use of dr.inference.model.Statistic in project beast-mcmc by beast-dev.

the class ExponentialStatisticParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    ExponentialStatistic expStatistic = null;
    Object child = xo.getChild(0);
    if (child instanceof Statistic) {
        expStatistic = new ExponentialStatistic(EXPONENTIAL_STATISTIC, (Statistic) child);
    } else {
        throw new XMLParseException("Unknown element found in " + getParserName() + " element:" + child);
    }
    return expStatistic;
}
Also used : ExponentialStatistic(dr.inference.model.ExponentialStatistic) Statistic(dr.inference.model.Statistic) ExponentialStatistic(dr.inference.model.ExponentialStatistic)

Example 13 with Statistic

use of dr.inference.model.Statistic in project beast-mcmc by beast-dev.

the class ImmutableParameterParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    final Statistic statistic = (Statistic) xo.getChild(Statistic.class);
    Parameter.Abstract immutableParameter = new Parameter.Abstract() {

        public void setParameterValueNotifyChangedAll(int dim, double value) {
            throw new RuntimeException("Forbidden call to ImmutableParameter.");
        }

        public void setParameterValueQuietly(int dim, double value) {
            throw new RuntimeException("Forbidden call to ImmutableParameter.");
        }

        public void storeValues() {
        //do nothing
        }

        public void restoreValues() {
        //do nothing
        }

        public void acceptValues() {
        //do nothing
        }

        public int getDimension() {
            return statistic.getDimension();
        }

        public void setParameterValue(int dim, double value) {
            throw new RuntimeException("Forbidden call to ImmutableParameter.");
        }

        public double getParameterValue(int dim) {
            return statistic.getStatisticValue(dim);
        }

        public String getParameterName() {
            if (getId() == null)
                return "immutable." + statistic.getStatisticName();
            return getId();
        }

        public void adoptValues(Parameter source) {
            throw new RuntimeException("Forbidden call to ImmutableParameter.");
        }

        public void addDimension(int index, double value) {
            throw new RuntimeException("Forbidden call to ImmutableParameter.");
        }

        public double removeDimension(int index) {
            throw new RuntimeException("Forbidden call to ImmutableParameter.");
        }

        public void addBounds(Bounds<Double> bounds) {
            throw new RuntimeException("Forbidden call to ImmutableParameter.");
        }

        public Bounds<Double> getBounds() {
            throw new RuntimeException("Forbidden call to ImmutableParameter.");
        }
    };
    return immutableParameter;
}
Also used : Statistic(dr.inference.model.Statistic) Bounds(dr.inference.model.Bounds) Parameter(dr.inference.model.Parameter)

Example 14 with Statistic

use of dr.inference.model.Statistic in project beast-mcmc by beast-dev.

the class LogarithmStatisticParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    LogarithmStatistic logStatistic;
    // base 0.0 means natural logarithm, the default base
    double base = xo.getAttribute(BASE, 0.0);
    if (base <= 1.0 && base != 0.0) {
        throw new XMLParseException("Error parsing " + getParserName() + " element: base attribute should be > 1");
    }
    Object child = xo.getChild(0);
    if (child instanceof Statistic) {
        logStatistic = new LogarithmStatistic(LOGARITHM_STATISTIC, (Statistic) child, base);
    } else {
        throw new XMLParseException("Unknown element found in " + getParserName() + " element:" + child);
    }
    return logStatistic;
}
Also used : LogarithmStatistic(dr.inference.model.LogarithmStatistic) Statistic(dr.inference.model.Statistic) LogarithmStatistic(dr.inference.model.LogarithmStatistic)

Example 15 with Statistic

use of dr.inference.model.Statistic in project beast-mcmc by beast-dev.

the class SumStatisticParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    boolean elementwise = xo.getAttribute(ELEMENTWISE, false);
    boolean absolute = xo.getAttribute(ABSOLUTE, false);
    String name = SUM_STATISTIC;
    if (xo.hasAttribute(Statistic.NAME)) {
        name = xo.getAttribute(Statistic.NAME, xo.getId());
    } else if (xo.hasAttribute(XMLParser.ID)) {
        name = xo.getAttribute(XMLParser.ID, xo.getId());
    }
    final SumStatistic sumStatistic = new SumStatistic(name, elementwise, absolute);
    for (int i = 0; i < xo.getChildCount(); i++) {
        final Statistic statistic = (Statistic) xo.getChild(i);
        try {
            sumStatistic.addStatistic(statistic);
        } catch (IllegalArgumentException iae) {
            throw new XMLParseException("Statistic added to " + getParserName() + " element is not of the same dimension");
        }
    }
    return sumStatistic;
}
Also used : Statistic(dr.inference.model.Statistic) SumStatistic(dr.inference.model.SumStatistic) SumStatistic(dr.inference.model.SumStatistic)

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