本文整理汇总了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);
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例6: modelRules
import dr.evomodel.speciation.SpeciationModel; //导入依赖的package包/类
private XMLSyntaxRule[] modelRules() {
return new XMLSyntaxRule[]{
new ElementRule(SpeciationModel.class)
};
}
示例7: MulSpeciesTreePrior
import dr.evomodel.speciation.SpeciationModel; //导入依赖的package包/类
public MulSpeciesTreePrior(SpeciationModel prior, MulSpeciesTreeModel mulsptree) {
super(prior);
this.mulsptree = mulsptree;
this.prior = prior;
}
示例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);
}
示例9: speciationModelSyntax
import dr.evomodel.speciation.SpeciationModel; //导入依赖的package包/类
private XMLSyntaxRule[] speciationModelSyntax() {
return new XMLSyntaxRule[]{
new ElementRule(SpeciationModel.class)
};
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}