Search in sources :

Example 1 with MultivariateDistribution

use of dr.math.distributions.MultivariateDistribution in project beast-mcmc by beast-dev.

the class ManyUniformGeoDistributionModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    List<GeoSpatialDistribution> distributions = new ArrayList<GeoSpatialDistribution>();
    List<Parameter> parameters = new ArrayList<Parameter>();
    List<Likelihood> oldLikelihood = new ArrayList<Likelihood>();
    for (int i = 0; i < xo.getChildCount(); ++i) {
        Object cxo = xo.getChild(i);
        MultivariateDistributionLikelihood ab = null;
        if (cxo instanceof MultivariateDistributionLikelihood) {
            ab = (MultivariateDistributionLikelihood) cxo;
        } else if (cxo instanceof CachedDistributionLikelihood) {
            ab = (MultivariateDistributionLikelihood) ((CachedDistributionLikelihood) cxo).getDistributionLikelihood();
        }
        if (ab != null) {
            parameters.add(ab.getDataParameter());
            MultivariateDistribution md = ab.getDistribution();
            oldLikelihood.add((Likelihood) cxo);
            if (md instanceof GeoSpatialDistribution) {
                distributions.add((GeoSpatialDistribution) md);
            } else {
                throw new XMLParseException("Unhandled distribution type in '" + xo.getId() + "'");
            }
        }
    }
    return new ManyUniformGeoDistributionModel(xo.getId(), parameters, distributions, oldLikelihood);
}
Also used : MultivariateDistributionLikelihood(dr.inference.distribution.MultivariateDistributionLikelihood) CachedDistributionLikelihood(dr.inference.distribution.CachedDistributionLikelihood) Likelihood(dr.inference.model.Likelihood) MultivariateDistributionLikelihood(dr.inference.distribution.MultivariateDistributionLikelihood) AbstractDistributionLikelihood(dr.inference.distribution.AbstractDistributionLikelihood) ArrayList(java.util.ArrayList) CachedDistributionLikelihood(dr.inference.distribution.CachedDistributionLikelihood) MultivariateDistribution(dr.math.distributions.MultivariateDistribution) Parameter(dr.inference.model.Parameter)

Example 2 with MultivariateDistribution

use of dr.math.distributions.MultivariateDistribution in project beast-mcmc by beast-dev.

the class GMRFSkyrideFixedEffectsGibbsOperatorParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
    GMRFSkyrideLikelihood gmrfLikelihood = (GMRFSkyrideLikelihood) xo.getChild(GMRFSkyrideLikelihood.class);
    MultivariateDistributionLikelihood likelihood = (MultivariateDistributionLikelihood) xo.getChild(MultivariateDistributionLikelihood.class);
    MultivariateDistribution prior = likelihood.getDistribution();
    if (prior.getType().compareTo(MultivariateNormalDistribution.TYPE) != 0)
        throw new XMLParseException("Only a multivariate normal distribution is conjugate for the regression coefficients in a GMRF");
    Parameter param = (Parameter) xo.getChild(Parameter.class);
    return new GMRFSkyrideFixedEffectsGibbsOperator(param, gmrfLikelihood, prior, weight);
}
Also used : MultivariateDistributionLikelihood(dr.inference.distribution.MultivariateDistributionLikelihood) MultivariateDistribution(dr.math.distributions.MultivariateDistribution) GMRFSkyrideLikelihood(dr.evomodel.coalescent.GMRFSkyrideLikelihood) Parameter(dr.inference.model.Parameter) GMRFSkyrideFixedEffectsGibbsOperator(dr.evomodel.coalescent.operators.GMRFSkyrideFixedEffectsGibbsOperator)

Aggregations

MultivariateDistributionLikelihood (dr.inference.distribution.MultivariateDistributionLikelihood)2 Parameter (dr.inference.model.Parameter)2 MultivariateDistribution (dr.math.distributions.MultivariateDistribution)2 GMRFSkyrideLikelihood (dr.evomodel.coalescent.GMRFSkyrideLikelihood)1 GMRFSkyrideFixedEffectsGibbsOperator (dr.evomodel.coalescent.operators.GMRFSkyrideFixedEffectsGibbsOperator)1 AbstractDistributionLikelihood (dr.inference.distribution.AbstractDistributionLikelihood)1 CachedDistributionLikelihood (dr.inference.distribution.CachedDistributionLikelihood)1 Likelihood (dr.inference.model.Likelihood)1 ArrayList (java.util.ArrayList)1