use of dr.inference.distribution.AbstractDistributionLikelihood in project beast-mcmc by beast-dev.
the class CachedDistributionLikelihoodParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
final String name = xo.hasId() ? xo.getId() : CACHED_PRIOR;
final AbstractDistributionLikelihood likelihood = (AbstractDistributionLikelihood) xo.getChild(AbstractDistributionLikelihood.class);
final Variable variable = (Variable) xo.getChild(Variable.class);
final Logger logger = Logger.getLogger("dr.inference");
logger.info("Constructing a cache around likelihood '" + likelihood.getId() + "', signal = " + variable.getVariableName());
return new CachedDistributionLikelihood(name, likelihood, variable);
}
use of dr.inference.distribution.AbstractDistributionLikelihood in project beast-mcmc by beast-dev.
the class UniformGeoSpatialOperatorParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
double weight = xo.getDoubleAttribute(MCMCOperator.WEIGHT);
Parameter parameter = (Parameter) xo.getChild(Parameter.class);
if (parameter.getDimension() == 0) {
throw new XMLParseException("parameter with 0 dimension.");
}
MultivariateDistributionLikelihood likelihood = (MultivariateDistributionLikelihood) xo.getChild(MultivariateDistributionLikelihood.class);
if (likelihood == null) {
CachedDistributionLikelihood cached = (CachedDistributionLikelihood) xo.getChild(CachedDistributionLikelihood.class);
AbstractDistributionLikelihood ab = cached.getDistributionLikelihood();
if (!(ab instanceof MultivariateDistributionLikelihood)) {
throw new XMLParseException("invalid likelihood type in " + xo.getId());
}
likelihood = (MultivariateDistributionLikelihood) ab;
}
List<AbstractPolygon2D> polygonList = new ArrayList<AbstractPolygon2D>();
if (likelihood.getDistribution() instanceof MultiRegionGeoSpatialDistribution) {
for (GeoSpatialDistribution spatial : ((MultiRegionGeoSpatialDistribution) likelihood.getDistribution()).getRegions()) {
polygonList.add(spatial.getRegion());
}
} else if (likelihood.getDistribution() instanceof GeoSpatialDistribution) {
polygonList.add(((GeoSpatialDistribution) likelihood.getDistribution()).getRegion());
} else {
throw new XMLParseException("Multivariate distribution must be either a GeoSpatialDistribution " + "or a MultiRegionGeoSpatialDistribution");
}
return new UniformGeoSpatialOperator(parameter, weight, polygonList);
}
Aggregations