Search in sources :

Example 6 with Distribution

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)));
    }
}
Also used : Distribution(dr.math.distributions.Distribution) PriorType(dr.app.beauti.types.PriorType) PDFPlot(dr.app.gui.chart.PDFPlot)

Example 7 with Distribution

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)));
    }
}
Also used : Distribution(dr.math.distributions.Distribution) PriorType(dr.app.beauti.types.PriorType) PDFPlot(dr.app.gui.chart.PDFPlot)

Example 8 with Distribution

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;
}
Also used : Distribution(dr.math.distributions.Distribution)

Example 9 with Distribution

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;
}
Also used : ModelSpecificPseudoPriorLikelihood(dr.inference.distribution.ModelSpecificPseudoPriorLikelihood) Distribution(dr.math.distributions.Distribution) Parameter(dr.inference.model.Parameter) DistributionLikelihood(dr.inference.distribution.DistributionLikelihood)

Example 10 with Distribution

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);
}
Also used : TwoPieceLocationScaleDistributionModel(dr.inference.distribution.TwoPieceLocationScaleDistributionModel) Distribution(dr.math.distributions.Distribution) Parameter(dr.inference.model.Parameter)

Aggregations

Distribution (dr.math.distributions.Distribution)10 PDFPlot (dr.app.gui.chart.PDFPlot)4 DistributionLikelihood (dr.inference.distribution.DistributionLikelihood)3 Parameter (dr.inference.model.Parameter)3 PriorType (dr.app.beauti.types.PriorType)2 GammaDistribution (dr.math.distributions.GammaDistribution)2 NormalDistribution (dr.math.distributions.NormalDistribution)2 OffsetPositiveDistribution (dr.math.distributions.OffsetPositiveDistribution)2 Tree (dr.evolution.tree.Tree)1 Taxa (dr.evolution.util.Taxa)1 Taxon (dr.evolution.util.Taxon)1 TaxonList (dr.evolution.util.TaxonList)1 CalibrationPoints (dr.evomodel.speciation.CalibrationPoints)1 SpeciationLikelihood (dr.evomodel.speciation.SpeciationLikelihood)1 SpeciationModel (dr.evomodel.speciation.SpeciationModel)1 ModelSpecificPseudoPriorLikelihood (dr.inference.distribution.ModelSpecificPseudoPriorLikelihood)1 TwoPartsDistributionLikelihood (dr.inference.distribution.TwoPartsDistributionLikelihood)1 TwoPieceLocationScaleDistributionModel (dr.inference.distribution.TwoPieceLocationScaleDistributionModel)1 Statistic (dr.inference.model.Statistic)1 LogFileTraces (dr.inference.trace.LogFileTraces)1