當前位置: 首頁>>代碼示例>>Java>>正文


Java SpeciationModel類代碼示例

本文整理匯總了Java中dr.evomodel.speciation.SpeciationModel的典型用法代碼示例。如果您正苦於以下問題:Java SpeciationModel類的具體用法?Java SpeciationModel怎麽用?Java SpeciationModel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SpeciationModel類屬於dr.evomodel.speciation包,在下文中一共展示了SpeciationModel類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testBirthDeathLikelihoodBEAST2

import dr.evomodel.speciation.SpeciationModel; //導入依賴的package包/類
public void testBirthDeathLikelihoodBEAST2() {
    System.out.println("RootHeight = " + tree2.getRootHeight());
    Variable<Double> origin = new Variable.D("origin", 6.0);

    final double birthRate = 2.0;
    final double deathRate = 1.0;
    final double psiRate = 0.5; // rate of sampling taxa through time
    final double sampleProbability = 0.0; // the proportion of taxa sampled, default to fix to 0
    final boolean hasFinalSample = false;
    Variable<Double> b = new Variable.D("b", birthRate);
    Variable<Double> d = new Variable.D("d", deathRate);
    Variable<Double> psi = new Variable.D("psi", psiRate);
    Variable<Double> p = new Variable.D("p", sampleProbability);
    Variable<Double> r = new Variable.D("r", 0.0); // sampleBecomesNonInfectiousProb

    SpeciationModel speciationModel = new BirthDeathSerialSamplingModel(b, d, psi, p, false, r, hasFinalSample, origin, Units.Type.YEARS);
    Likelihood likelihood = new SpeciationLikelihood(tree2, speciationModel, "bdss.like");

    assertEquals(-19.0198, likelihood.getLogLikelihood(), 1e-5);
}
 
開發者ID:beast-dev,項目名稱:beast-mcmc,代碼行數:21,代碼來源:BirthDeathSSLikelihoodTest.java

示例2: birthDeathLikelihoodTester

import dr.evomodel.speciation.SpeciationModel; //導入依賴的package包/類
private void birthDeathLikelihoodTester(
        Tree tree, double birthRate, double deathRate, double logL) {

    Parameter b = new Parameter.Default("b", birthRate, 0.0, Double.MAX_VALUE);
    Parameter d = new Parameter.Default("d", deathRate, 0.0, Double.MAX_VALUE);

    SpeciationModel speciationModel = new BirthDeathGernhard08Model(b, d, null, BirthDeathGernhard08Model.TreeType.ORIENTED,
            Units.Type.YEARS);
    Likelihood likelihood = new SpeciationLikelihood(tree, speciationModel, "bd.like");

    assertEquals(logL, likelihood.getLogLikelihood(), 1e-14);
}
 
開發者ID:beast-dev,項目名稱:beast-mcmc,代碼行數:13,代碼來源:BirthDeathLikelihoodTest.java

示例3: likelihoodTester

import dr.evomodel.speciation.SpeciationModel; //導入依賴的package包/類
private void likelihoodTester(Tree tree, double birthRate, double deathRate, Variable<Double> origin, double logL) {

        Variable<Double> b = new Variable.D("b", birthRate);
        Variable<Double> d = new Variable.D("d", deathRate);
        Variable<Double> psi = new Variable.D("psi", this.psi);
        Variable<Double> p = new Variable.D("p", this.p);
        Variable<Double> r = new Variable.D("r", 0.5);
        Variable<Double> fTime = new Variable.D("time", 0.0);

        SpeciationModel speciationModel = new BirthDeathSerialSamplingModel(b, d, psi, p, false, r, true, origin, Units.Type.YEARS);
        Likelihood likelihood = new SpeciationLikelihood(tree, speciationModel, "bdss.like");

        assertEquals(logL, likelihood.getLogLikelihood());
    }
 
開發者ID:beast-dev,項目名稱:beast-mcmc,代碼行數:15,代碼來源:BirthDeathSSLikelihoodTest.java

示例4: parseXMLObject

import dr.evomodel.speciation.SpeciationModel; //導入依賴的package包/類
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
	final XMLObject mxo = xo.getChild(MODEL);
	final SpeciationModel sppm = (SpeciationModel) mxo.getChild(SpeciationModel.class);
	final XMLObject mulsptxo = xo.getChild(MUL_SPECIES_TREE);
	final MulSpeciesTreeModel mulspt = (MulSpeciesTreeModel) mulsptxo.getChild(MulSpeciesTreeModel.class);
	return new MulSpeciesTreePrior(sppm, mulspt);	
}
 
開發者ID:whdc,項目名稱:ieo-beast,代碼行數:9,代碼來源:MulSpeciesTreePriorParser.java

示例5: parseXMLObject

import dr.evomodel.speciation.SpeciationModel; //導入依賴的package包/類
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    System.out.println("PopsIOSpeciesTreePriorParser");
    final XMLObject mxo = xo.getChild(MODEL);
    final SpeciationModel sppm = (SpeciationModel) mxo.getChild(SpeciationModel.class);
    final XMLObject mulsptxo = xo.getChild(PIO_TREE);
    final PopsIOSpeciesTreeModel piostm = (PopsIOSpeciesTreeModel) mulsptxo.getChild(PopsIOSpeciesTreeModel.class);
    return new PopsIOSpeciesTreePrior(sppm, piostm);
}
 
開發者ID:whdc,項目名稱:ieo-beast,代碼行數:10,代碼來源:PopsIOSpeciesTreePriorParser.java

示例6: modelRules

import dr.evomodel.speciation.SpeciationModel; //導入依賴的package包/類
private  XMLSyntaxRule[] modelRules() {
    return new XMLSyntaxRule[]{
            new ElementRule(SpeciationModel.class)
    };
}
 
開發者ID:beast-dev,項目名稱:beast-mcmc,代碼行數:6,代碼來源:MulSpeciesTreePriorParser.java

示例7: MulSpeciesTreePrior

import dr.evomodel.speciation.SpeciationModel; //導入依賴的package包/類
public MulSpeciesTreePrior(SpeciationModel prior, MulSpeciesTreeModel mulsptree) {
	super(prior);
	this.mulsptree = mulsptree;
	this.prior = prior;
}
 
開發者ID:beast-dev,項目名稱:beast-mcmc,代碼行數:6,代碼來源:MulSpeciesTreePrior.java

示例8: randomLocalYuleTester

import dr.evomodel.speciation.SpeciationModel; //導入依賴的package包/類
private void randomLocalYuleTester(TreeModel treeModel, Parameter I, Parameter b, OperatorSchedule schedule) {

        MCMC mcmc = new MCMC("mcmc1");
        MCMCOptions options = new MCMCOptions(1000000);

        TreeLengthStatistic tls = new TreeLengthStatistic(TL, treeModel);
        TreeHeightStatistic rootHeight = new TreeHeightStatistic(TREE_HEIGHT, treeModel);

        Parameter m = new Parameter.Default("m", 1.0, 0.0, Double.MAX_VALUE);

        SpeciationModel speciationModel = new RandomLocalYuleModel(b, I, m, false, Units.Type.YEARS, 4);

        Likelihood likelihood = new SpeciationLikelihood(treeModel, speciationModel, "randomYule.like");

        ArrayLogFormatter formatter = new ArrayLogFormatter(false);

        MCLogger[] loggers = new MCLogger[2];
        loggers[0] = new MCLogger(formatter, 100, false);
        loggers[0].add(likelihood);
        loggers[0].add(rootHeight);
        loggers[0].add(tls);
        loggers[0].add(I);

        loggers[1] = new MCLogger(new TabDelimitedFormatter(System.out), 100000, false);
        loggers[1].add(likelihood);
        loggers[1].add(rootHeight);
        loggers[1].add(tls);
        loggers[1].add(I);

        mcmc.setShowOperatorAnalysis(true);

        mcmc.init(options, likelihood, schedule, loggers);

        mcmc.run();

        List<Trace> traces = formatter.getTraces();
        ArrayTraceList traceList = new ArrayTraceList("yuleModelTest", traces, 0);

        for (int i = 1; i < traces.size(); i++) {
            traceList.analyseTrace(i);
        }

        TraceCorrelation tlStats =
                traceList.getCorrelationStatistics(traceList.getTraceIndex("root." + birthRateIndicator));

        System.out.println("mean = " + tlStats.getMean());
        System.out.println("expected mean = 0.5");

        assertExpectation("root." + birthRateIndicator, tlStats, 0.5);
    }
 
開發者ID:beast-dev,項目名稱:beast-mcmc,代碼行數:51,代碼來源:RLYModelTest.java

示例9: speciationModelSyntax

import dr.evomodel.speciation.SpeciationModel; //導入依賴的package包/類
private  XMLSyntaxRule[] speciationModelSyntax() {
    return new XMLSyntaxRule[]{
            new ElementRule(SpeciationModel.class)
    };

}
 
開發者ID:whdc,項目名稱:ieo-beast,代碼行數:7,代碼來源:PopsIOSpeciesTreePriorParser.java

示例10: yuleTester

import dr.evomodel.speciation.SpeciationModel; //導入依賴的package包/類
private void yuleTester(TreeModel treeModel, OperatorSchedule schedule) {

        MCMC mcmc = new MCMC("mcmc1");
        MCMCOptions options = new MCMCOptions();
        options.setChainLength(1000000);
        options.setUseCoercion(true);
        options.setCoercionDelay(100);
        options.setTemperature(1.0);
        options.setFullEvaluationCount(2000);

        TreeLengthStatistic tls = new TreeLengthStatistic(TL, treeModel);
        TreeHeightStatistic rootHeight = new TreeHeightStatistic(TREE_HEIGHT, treeModel);

        Parameter b = new Parameter.Default("b", 2.0, 0.0, Double.MAX_VALUE);
        Parameter d = new Parameter.Default("d", 0.0, 0.0, Double.MAX_VALUE);

        SpeciationModel speciationModel = new BirthDeathGernhard08Model(b, d, null, BirthDeathGernhard08Model.TreeType.TIMESONLY,
                Units.Type.YEARS);
        Likelihood likelihood = new SpeciationLikelihood(treeModel, speciationModel, "yule.like");

        ArrayLogFormatter formatter = new ArrayLogFormatter(false);

        MCLogger[] loggers = new MCLogger[2];
        loggers[0] = new MCLogger(formatter, 100, false);
        loggers[0].add(likelihood);
        loggers[0].add(rootHeight);
        loggers[0].add(tls);

        loggers[1] = new MCLogger(new TabDelimitedFormatter(System.out), 100000, false);
        loggers[1].add(likelihood);
        loggers[1].add(rootHeight);
        loggers[1].add(tls);

        mcmc.setShowOperatorAnalysis(true);

        mcmc.init(options, likelihood, schedule, loggers);

        mcmc.run();

        List<Trace> traces = formatter.getTraces();
        ArrayTraceList traceList = new ArrayTraceList("yuleModelTest", traces, 0);

        for (int i = 1; i < traces.size(); i++) {
            traceList.analyseTrace(i);
        }

        // expectation of root height for 4 tips and lambda = 2
        // rootHeight = 0.541666
        // TL = 1.5

        TraceCorrelation tlStats =
                traceList.getCorrelationStatistics(traceList.getTraceIndex(TL));

        assertExpectation(TL, tlStats, 1.5);

        TraceCorrelation treeHeightStats =
                traceList.getCorrelationStatistics(traceList.getTraceIndex(TREE_HEIGHT));

        assertExpectation(TREE_HEIGHT, treeHeightStats, 0.5416666);


    }
 
開發者ID:whdc,項目名稱:ieo-beast,代碼行數:63,代碼來源:YuleModelTest.java

示例11: randomLocalYuleTester

import dr.evomodel.speciation.SpeciationModel; //導入依賴的package包/類
private void randomLocalYuleTester(TreeModel treeModel, Parameter I, Parameter b, OperatorSchedule schedule) {

        MCMC mcmc = new MCMC("mcmc1");
        MCMCOptions options = new MCMCOptions();
        options.setChainLength(1000000);
        options.setUseCoercion(true);
        options.setCoercionDelay(100);
        options.setTemperature(1.0);
        options.setFullEvaluationCount(2000);

        TreeLengthStatistic tls = new TreeLengthStatistic(TL, treeModel);
        TreeHeightStatistic rootHeight = new TreeHeightStatistic(TREE_HEIGHT, treeModel);

        Parameter m = new Parameter.Default("m", 1.0, 0.0, Double.MAX_VALUE);

        SpeciationModel speciationModel = new RandomLocalYuleModel(b, I, m, false, Units.Type.YEARS, 4);

        Likelihood likelihood = new SpeciationLikelihood(treeModel, speciationModel, "randomYule.like");

        ArrayLogFormatter formatter = new ArrayLogFormatter(false);

        MCLogger[] loggers = new MCLogger[2];
        loggers[0] = new MCLogger(formatter, 100, false);
        loggers[0].add(likelihood);
        loggers[0].add(rootHeight);
        loggers[0].add(tls);
        loggers[0].add(I);

        loggers[1] = new MCLogger(new TabDelimitedFormatter(System.out), 100000, false);
        loggers[1].add(likelihood);
        loggers[1].add(rootHeight);
        loggers[1].add(tls);
        loggers[1].add(I);

        mcmc.setShowOperatorAnalysis(true);

        mcmc.init(options, likelihood, schedule, loggers);

        mcmc.run();

        List<Trace> traces = formatter.getTraces();
        ArrayTraceList traceList = new ArrayTraceList("yuleModelTest", traces, 0);

        for (int i = 1; i < traces.size(); i++) {
            traceList.analyseTrace(i);
        }

        TraceCorrelation tlStats =
                traceList.getCorrelationStatistics(traceList.getTraceIndex("root." + birthRateIndicator));

        System.out.println("mean = " + tlStats.getMean());
        System.out.println("expected mean = 0.5");

        assertExpectation("root." + birthRateIndicator, tlStats, 0.5);
    }
 
開發者ID:whdc,項目名稱:ieo-beast,代碼行數:56,代碼來源:RLYModelTest.java

示例12: yuleLikelihoodTester

import dr.evomodel.speciation.SpeciationModel; //導入依賴的package包/類
private void yuleLikelihoodTester(Tree tree, double birthRate, double logL) {

        Parameter b = new Parameter.Default("b", birthRate, 0.0, Double.MAX_VALUE);
        Parameter d = new Parameter.Default("d", 0.0, 0.0, Double.MAX_VALUE);

        SpeciationModel speciationModel = new BirthDeathGernhard08Model(b, d, null, BirthDeathGernhard08Model.TreeType.TIMESONLY,
                Units.Type.YEARS);
        Likelihood likelihood = new SpeciationLikelihood(tree, speciationModel, "yule.like");

        assertEquals(likelihood.getLogLikelihood(), logL);

    }
 
開發者ID:beast-dev,項目名稱:beast-mcmc,代碼行數:13,代碼來源:YuleLikelihoodTest.java

示例13: yuleTester

import dr.evomodel.speciation.SpeciationModel; //導入依賴的package包/類
private void yuleTester(TreeModel treeModel, OperatorSchedule schedule) {

        MCMC mcmc = new MCMC("mcmc1");
        MCMCOptions options = new MCMCOptions(1000000);

        TreeLengthStatistic tls = new TreeLengthStatistic(TL, treeModel);
        TreeHeightStatistic rootHeight = new TreeHeightStatistic(TREE_HEIGHT, treeModel);

        Parameter b = new Parameter.Default("b", 2.0, 0.0, Double.MAX_VALUE);
        Parameter d = new Parameter.Default("d", 0.0, 0.0, Double.MAX_VALUE);

        SpeciationModel speciationModel = new BirthDeathGernhard08Model(b, d, null, BirthDeathGernhard08Model.TreeType.TIMESONLY,
                Units.Type.YEARS);
        Likelihood likelihood = new SpeciationLikelihood(treeModel, speciationModel, "yule.like");

        ArrayLogFormatter formatter = new ArrayLogFormatter(false);

        MCLogger[] loggers = new MCLogger[2];
        loggers[0] = new MCLogger(formatter, 100, false);
        loggers[0].add(likelihood);
        loggers[0].add(rootHeight);
        loggers[0].add(tls);

        loggers[1] = new MCLogger(new TabDelimitedFormatter(System.out), 100000, false);
        loggers[1].add(likelihood);
        loggers[1].add(rootHeight);
        loggers[1].add(tls);

        mcmc.setShowOperatorAnalysis(true);

        mcmc.init(options, likelihood, schedule, loggers);

        mcmc.run();

        List<Trace> traces = formatter.getTraces();
        ArrayTraceList traceList = new ArrayTraceList("yuleModelTest", traces, 0);

        for (int i = 1; i < traces.size(); i++) {
            traceList.analyseTrace(i);
        }

        // expectation of root height for 4 tips and lambda = 2
        // rootHeight = 0.541666
        // TL = 1.5

        TraceCorrelation tlStats =
                traceList.getCorrelationStatistics(traceList.getTraceIndex(TL));

        assertExpectation(TL, tlStats, 1.5);

        TraceCorrelation treeHeightStats =
                traceList.getCorrelationStatistics(traceList.getTraceIndex(TREE_HEIGHT));

        assertExpectation(TREE_HEIGHT, treeHeightStats, 0.5416666);


    }
 
開發者ID:beast-dev,項目名稱:beast-mcmc,代碼行數:58,代碼來源:YuleModelTest.java


注:本文中的dr.evomodel.speciation.SpeciationModel類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。