use of dr.math.distributions.Distribution in project beast-mcmc by beast-dev.
the class PriorSettingsPanel method setupChart.
void setupChart() {
chart.removeAllPlots();
if (hasInvalidInput(false)) {
quantileText.setText("Invalid input");
return;
}
PriorType priorType = (PriorType) priorCombo.getSelectedItem();
if (priorType == null) {
priorType = parameter.priorType;
priorCombo.setSelectedItem(priorType);
}
// ExponentialDistribution(1.0 / mean)
// if (priorType == PriorType.EXPONENTIAL_PRIOR && parameter.mean == 0) parameter.mean = 1;
PriorOptionsPanel priorOptionsPanel = optionsPanels.get(priorType);
// TODO is this used or duplicated to OffsetPositiveDistribution?
double offset = 0.0;
// this does not refresh dist from parameter truncation lower/upper, it get them from GUI
Distribution distribution = priorOptionsPanel.getDistribution(parameter);
chart.addPlot(new PDFPlot(distribution, offset));
if (distribution != null) {
quantileText.setText(formatter.format(distribution.quantile(0.025)) + "\n" + formatter.format(distribution.quantile(0.05)) + "\n" + formatter.format(distribution.quantile(0.5)) + "\n" + formatter.format(distribution.quantile(0.95)) + "\n" + formatter.format(distribution.quantile(0.975)));
}
}
use of dr.math.distributions.Distribution in project beast-mcmc by beast-dev.
the class PriorSettingsPanel method setupChart.
void setupChart() {
chart.removeAllPlots();
if (hasInvalidInput(false)) {
quantileText.setText("Invalid input");
return;
}
PriorType priorType = (PriorType) priorCombo.getSelectedItem();
if (priorType == null) {
priorType = parameter.priorType;
priorCombo.setSelectedItem(priorType);
}
PriorOptionsPanel priorOptionsPanel = optionsPanels.get(priorType);
// TODO is this used or duplicated to OffsetPositiveDistribution?
double offset = 0.0;
// this does not refresh dist from parameter truncation lower/upper, it get them from GUI
Distribution distribution = priorOptionsPanel.getDistribution(parameter);
chart.addPlot(new PDFPlot(distribution, offset));
if (distribution != null) {
quantileText.setText(formatter.format(distribution.quantile(0.025)) + "\n" + formatter.format(distribution.quantile(0.05)) + "\n" + formatter.format(distribution.quantile(0.5)) + "\n" + formatter.format(distribution.quantile(0.95)) + "\n" + formatter.format(distribution.quantile(0.975)));
}
}
use of dr.math.distributions.Distribution in project beast-mcmc by beast-dev.
the class Parameter method getPriorExpectationMean.
public double getPriorExpectationMean() {
double expMean = 1.0;
Distribution dist = priorType.getDistributionInstance(this);
if (dist != null) {
expMean = dist.mean();
if (expMean == 0) {
expMean = dist.quantile(0.975);
}
if (expMean == 0) {
expMean = 1.0;
}
}
return expMean;
}
use of dr.math.distributions.Distribution in project beast-mcmc by beast-dev.
the class ModelSpecificPseudoPriorLikelihoodParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
DistributionLikelihood priorLikelihood = (DistributionLikelihood) xo.getElementFirstChild(PRIOR);
DistributionLikelihood pseudoPriorLikelihood = (DistributionLikelihood) xo.getElementFirstChild(PSEUDO_PRIOR);
Distribution prior = priorLikelihood.getDistribution();
Distribution pseudoPrior = pseudoPriorLikelihood.getDistribution();
Parameter modelIndicator = (Parameter) xo.getElementFirstChild(MODEL_INDICATOR);
int[] models = xo.getIntegerArrayAttribute(MODELS);
Parameter selectedVariable = (Parameter) xo.getElementFirstChild(SELECTED_VARIABLE);
ModelSpecificPseudoPriorLikelihood likelihood = new ModelSpecificPseudoPriorLikelihood(prior, pseudoPrior, modelIndicator, models);
likelihood.addData(selectedVariable);
return likelihood;
}
use of dr.math.distributions.Distribution 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