use of dr.inference.distribution.InverseGaussianDistributionModel in project beast-mcmc by beast-dev.
the class PartitionData method createClockRateModel.
public BranchRateModel createClockRateModel() {
BranchRateModel branchRateModel = null;
if (this.clockModelIndex == 0) {
// Strict Clock
Parameter rateParameter = new Parameter.Default(1, clockParameterValues[0]);
branchRateModel = new StrictClockBranchRates(rateParameter);
} else if (this.clockModelIndex == LRC_INDEX) {
// Lognormal relaxed clock
double numberOfBranches = 2 * (createTreeModel().getTaxonCount() - 1);
Parameter rateCategoryParameter = new Parameter.Default(numberOfBranches);
Parameter mean = new Parameter.Default(LogNormalDistributionModelParser.MEAN, 1, clockParameterValues[1]);
Parameter stdev = new Parameter.Default(LogNormalDistributionModelParser.STDEV, 1, clockParameterValues[2]);
//TODO: choose between log scale / real scale
ParametricDistributionModel distributionModel = new LogNormalDistributionModel(mean, stdev, clockParameterValues[3], lrcParametersInRealSpace, lrcParametersInRealSpace);
branchRateModel = new //
DiscretizedBranchRates(//
createTreeModel(), //
rateCategoryParameter, //
distributionModel, //
1, //
false, //
Double.NaN, //randomizeRates
true, // keepRates
false, // cacheRates
false);
} else if (this.clockModelIndex == 2) {
// Exponential relaxed clock
double numberOfBranches = 2 * (createTreeModel().getTaxonCount() - 1);
Parameter rateCategoryParameter = new Parameter.Default(numberOfBranches);
Parameter mean = new Parameter.Default(DistributionModelParser.MEAN, 1, clockParameterValues[4]);
ParametricDistributionModel distributionModel = new ExponentialDistributionModel(mean, clockParameterValues[5]);
// branchRateModel = new DiscretizedBranchRates(createTreeModel(), rateCategoryParameter,
// distributionModel, 1, false, Double.NaN);
branchRateModel = new //
DiscretizedBranchRates(//
createTreeModel(), //
rateCategoryParameter, //
distributionModel, //
1, //
false, //
Double.NaN, //randomizeRates
true, // keepRates
false, // cacheRates
false);
} else if (this.clockModelIndex == 3) {
// Inverse Gaussian
double numberOfBranches = 2 * (createTreeModel().getTaxonCount() - 1);
Parameter rateCategoryParameter = new Parameter.Default(numberOfBranches);
Parameter mean = new Parameter.Default(InverseGaussianDistributionModelParser.MEAN, 1, clockParameterValues[6]);
Parameter stdev = new Parameter.Default(InverseGaussianDistributionModelParser.STDEV, 1, clockParameterValues[7]);
ParametricDistributionModel distributionModel = new InverseGaussianDistributionModel(mean, stdev, clockParameterValues[8], false);
branchRateModel = new //
DiscretizedBranchRates(//
createTreeModel(), //
rateCategoryParameter, //
distributionModel, //
1, //
false, //
Double.NaN, //randomizeRates
true, // keepRates
false, // cacheRates
false);
} else {
System.out.println("Not yet implemented");
}
return branchRateModel;
}
use of dr.inference.distribution.InverseGaussianDistributionModel in project beast-mcmc by beast-dev.
the class InverseGaussianDistributionModelParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
Parameter meanParam;
double offset = xo.getAttribute(OFFSET, 0.0);
XMLObject cxo = xo.getChild(MEAN);
if (cxo.getChild(0) instanceof Parameter) {
meanParam = (Parameter) cxo.getChild(Parameter.class);
} else {
meanParam = new Parameter.Default(cxo.getDoubleChild(0));
}
if (xo.hasChildNamed(STDEV) && xo.hasChildNamed(SHAPE)) {
throw new RuntimeException("XML has both standard deviation and shape for Inverse Gaussian distribution");
} else if (xo.hasChildNamed(STDEV)) {
Parameter stdevParam;
cxo = xo.getChild(STDEV);
if (cxo.getChild(0) instanceof Parameter) {
stdevParam = (Parameter) cxo.getChild(Parameter.class);
} else {
stdevParam = new Parameter.Default(cxo.getDoubleChild(0));
}
return new InverseGaussianDistributionModel(meanParam, stdevParam, offset, false);
} else if (xo.hasChildNamed(SHAPE)) {
Parameter shapeParam;
cxo = xo.getChild(SHAPE);
if (cxo.getChild(0) instanceof Parameter) {
shapeParam = (Parameter) cxo.getChild(Parameter.class);
} else {
shapeParam = new Parameter.Default(cxo.getDoubleChild(0));
}
return new InverseGaussianDistributionModel(meanParam, shapeParam, offset, true);
} else {
throw new RuntimeException("XML has neither standard deviation nor shape for Inverse Gaussian distribution");
}
}
Aggregations