use of dr.inference.distribution.TwoPieceLocationScaleDistributionModel in project beast-mcmc by beast-dev.
the class TwoPieceLocationScaleDistributionModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Parameter locationParam;
Parameter sigmaParam;
Parameter gammaParam;
XMLObject cxo = xo.getChild(LOCATION);
if (cxo.getChild(0) instanceof Parameter) {
locationParam = (Parameter) cxo.getChild(Parameter.class);
} else {
locationParam = new Parameter.Default(cxo.getDoubleChild(0));
}
String parameterizationLabel = (String) xo.getAttribute(PARAMETERIZATION);
TwoPieceLocationScaleDistributionModel.Parameterization parameterization = TwoPieceLocationScaleDistributionModel.Parameterization.parseFromString(parameterizationLabel);
if (parameterization == null) {
throw new XMLParseException("Unrecognized parameterization '" + parameterizationLabel + "'");
}
cxo = xo.getChild(SIGMA);
if (cxo.getChild(0) instanceof Parameter) {
sigmaParam = (Parameter) cxo.getChild(Parameter.class);
} else {
sigmaParam = new Parameter.Default(cxo.getDoubleChild(0));
}
cxo = xo.getChild(GAMMA);
if (cxo.getChild(0) instanceof Parameter) {
gammaParam = (Parameter) cxo.getChild(Parameter.class);
} else {
gammaParam = new Parameter.Default(cxo.getDoubleChild(0));
}
Distribution distribution = (Distribution) xo.getChild(Distribution.class);
return new TwoPieceLocationScaleDistributionModel(locationParam, distribution, sigmaParam, gammaParam, parameterization);
}
Aggregations