当前位置: 首页>>代码示例>>Java>>正文


Java RealParameter.initByName方法代码示例

本文整理汇总了Java中beast.core.parameter.RealParameter.initByName方法的典型用法代码示例。如果您正苦于以下问题:Java RealParameter.initByName方法的具体用法?Java RealParameter.initByName怎么用?Java RealParameter.initByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在beast.core.parameter.RealParameter的用法示例。


在下文中一共展示了RealParameter.initByName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: MissingDataConstantIO

import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
public MissingDataConstantIO() throws Exception {
    ploidy = 2.0;
    nSpecies = 4;
    expectedLogP = -10.956285249389675; // haven't checked this is the right answer

    state = new State();
    alphaParameter = new RealParameter();
    meanParameter = new RealParameter();

    alphaParameter.initByName("value", String.valueOf(alpha));
    meanParameter.initByName("value", String.valueOf(mean));
    
    newickSpeciesTree = "((s0:0.32057156677143211,s3:0.32057156677143211):1.2653250035015629,(s1:0.56540722294658641,s2:0.56540722294658641):1.0204893473264085)";
    newickGeneTrees.add("((((s0_tip1:0.3416660303037105,s3_tip0:0.3416660303037105):0.024561190897159135,s0_tip0:0.36622722120086965):0.0643095990846464,s3_tip1:0.43053682028551604):1.4201019862262891,(s2_tip0:0.19897724687831703,s2_tip1:0.19897724687831703):1.651661559633488)");
    newickGeneTrees.add("((s3_tip0:0.09482581277282173,s3_tip1:0.09482581277282173):1.6017973588278296,((s1_tip0:0.33170960882423645,s1_tip1:0.33170960882423645):0.29497523293318856,(s2_tip0:0.2908611340994834,s2_tip1:0.2908611340994834):0.3358237076579416):1.0699383298432266)");
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:17,代码来源:MissingDataConstantIO.java

示例2: ConstantIOTest

import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
public ConstantIOTest() throws Exception {
    ploidy = 2.0;
    nSpecies = 4;
    expectedLogP = -14.5233984762; // this should be the right answer (calculated by hand)

    state = new State();
    alphaParameter = new RealParameter();
    meanParameter = new RealParameter();

    alphaParameter.initByName("value", String.valueOf(alpha));
    meanParameter.initByName("value", String.valueOf(mean));

    newickSpeciesTree = "((s0:0.32057156677143211,s3:0.32057156677143211):1.2653250035015629,(s1:0.56540722294658641,s2:0.56540722294658641):1.0204893473264085)";
    newickGeneTrees.add("((((s0_tip1:0.3416660303037105,s3_tip0:0.3416660303037105):0.024561190897159135,s0_tip0:0.36622722120086965):0.0643095990846464,s3_tip1:0.43053682028551604):1.4201019862262891,((s1_tip0:0.14473698225381706,s1_tip1:0.14473698225381706):0.5135479407233198,(s2_tip0:0.19897724687831703,s2_tip1:0.19897724687831703):0.4593076760988198):1.1923538835346683)");
    newickGeneTrees.add("(((s0_tip0:0.04173231934154758,s0_tip1:0.04173231934154758):0.7845256741090114,(s3_tip0:0.09482581277282173,s3_tip1:0.09482581277282173):0.7314321806777372):0.8703651781500925,((s1_tip0:0.33170960882423645,s1_tip1:0.33170960882423645):0.29497523293318856,(s2_tip0:0.2908611340994834,s2_tip1:0.2908611340994834):0.3358237076579416):1.0699383298432266)");
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:17,代码来源:ConstantIOTest.java

示例3: testRates

import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
@Test
public void testRates() throws Exception {
    initializeTree();

    meanRateParameter = new RealParameter();
    stdevParameter = new RealParameter();
    branchRatesParameter = new IntegerParameter();

    meanRateParameter.initByName("value", String.valueOf(meanRate));
    stdevParameter.initByName("value", String.valueOf(1.0));
    branchRatesParameter.initByName("value", String.valueOf(initialBranchRate));

    // Create dummy state to allow statenode editing
    State state = new State();
    state.initByName("stateNode", meanRateParameter);
    state.initByName("stateNode", branchRatesParameter);
    state.initialise();

    clockModel = new UncorrelatedRates();
    clockModel.initByName("tree", testTree, "rates", branchRatesParameter, "stdev", stdevParameter, "estimateRoot", false, "clock.rate", meanRateParameter);

    initializeRates();
    checkRates();
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:25,代码来源:UncorrelatedRatesTest.java

示例4: getEmpericalFrequencieValues

import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
/**
 * convert empirical frequencies into a RealParameter *
 */
Frequencies getEmpericalFrequencieValues() {
    double[] freqs = getEmpiricalFrequencies();
    int[] order = getEncodingOrder();
    int states = freqs.length;
    Frequencies freqsParam = new Frequencies();
    String valuesString = "";

    for (int i = 0; i < states; i++) {
        valuesString += freqs[order[i]] + " ";
    }
    RealParameter freqsRParam = new RealParameter();
    freqsRParam.initByName(
            "value", valuesString,
            "lower", 0.0,
            "upper", 1.0,
            "dimension", states
    );
    freqsParam.frequenciesInput.setValue(freqsRParam, freqsParam);
    freqsParam.initAndValidate();
    return freqsParam;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:25,代码来源:EmpiricalSubstitutionModel.java

示例5: testMultinomial

import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
public void testMultinomial() throws Exception{
    for(Instance test: all){
        RealParameter probs = new RealParameter();
        IntegerParameter x  = new IntegerParameter();
        probs.initByName(
                "value",test.getProbs(),
                "lower","0",
                "upper","1");
        x.initByName("value", test.getX(),
                "lower", "0",
                "upper", "100000000");
        Multinomial multiNom = new Multinomial();
        multiNom.initByName("probs", probs);
        double fLogX = multiNom.calcLogP(x);
        assertEquals(fLogX, test.getFLogX(), 1e-10);

    }
}
 
开发者ID:jessiewu,项目名称:substBMA,代码行数:19,代码来源:MultinomialTest.java

示例6: testRates

import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
@Test
public void testRates() throws Exception {
    TaxonSet speciesSuperSet = generateSuperset();
    initializeTrees(speciesSuperSet);

    meanRateParameter = new RealParameter();
    stdevParameter = new RealParameter();
    branchRatesParameter = new IntegerParameter();

    meanRateParameter.initByName("value", String.valueOf(meanRate));
    stdevParameter.initByName("value", String.valueOf(1.0));
    branchRatesParameter.initByName("value", String.valueOf(initialBranchRate));

    // Create dummy state to allow statenode editing
    State state = new State();
    state.initByName("stateNode", meanRateParameter);
    state.initByName("stateNode", branchRatesParameter);
    state.initialise();

    speciesTreeClock = new UncorrelatedRates();
    speciesTreeClock.initByName("tree", speciesTree, "rates", branchRatesParameter, "stdev", stdevParameter, "estimateRoot", true);
    initializeRates();

    geneTreeClock = new StarBeastClock();
    geneTreeClock.initByName("geneTree", geneTreeWrapper, "speciesTreeRates", speciesTreeClock, "clock.rate", meanRateParameter);
    checkRates();
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:28,代码来源:StarbeastClockTest.java

示例7: getPrecision

import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
public RealParameter getPrecision()throws Exception{



            RealParameter precision = new RealParameter();
            precision.initByName(
                    "value",
                    "1.0000000 0.9529819 0.3554853 0.1695793 " +
                            "0.9529819 2.0000000 0.3658894 0.6902582 " +
                            "0.3554853 0.3658894 1.5000000 0.8099044 " +
                            "0.1695793 0.6902582 0.8099044 1.3000000"
            );
            //System.out.println(precision==null);
            return precision;
        }
 
开发者ID:jessiewu,项目名称:substBMA,代码行数:16,代码来源:MultivariateNormalTest.java

示例8: testDiscrete

import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
public void testDiscrete() throws Exception{
    for(Instance test: all){

        RealParameter probs = new RealParameter();

        probs.initByName(
                "value",test.getProbs(),
                "lower","0",
                "upper","1");

        int[] xVals = test.getXs();
        CategoricalDistribution dist = new CategoricalDistribution();
        dist.initByName("probs", probs);
        for(int i = 0; i < xVals.length; i++){

            IntegerParameter x  = new IntegerParameter();
            x.initByName("value", ""+xVals[i],
                    "lower", "0",
                    "upper", "100000000");

            double fLogX = dist.calcLogP(x);
            assertEquals(fLogX, test.getFLogX()[i], 1e-10);


        }
        double p = test.getDouble();
        int invProb = (int)dist.inverseCumulativeProbability(p);
        //System.err.println(invProb+" "+test.getInverseProb());
        assertEquals(invProb, test.getInverseProb(), 1e-10);

    }
}
 
开发者ID:jessiewu,项目名称:substBMA,代码行数:33,代码来源:CategoricalDistributionTest.java

示例9: testLogHR

import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
@Test
public void testLogHR() throws Exception {
    TaxonSet speciesSuperSet = generateSuperset();
    initializeSpeciesTree(speciesSuperSet);
    initializeGeneTrees();

    popsizeParameter = new RealParameter();
    popsizeParameter.initByName("value", String.valueOf(popSize));

    // Create dummy state to allow statenode editing
    State state = new State();
    state.initByName("stateNode", popsizeParameter);
    for (Tree gt: geneTrees) {
        state.initByName("stateNode", gt);
    }
    state.initialise();

    populationModel = new ConstantPopulations();
    populationModel.initByName("populationSizes", popsizeParameter, "speciesTree", speciesTreeWrapper);

    int nBranches = speciesTreeWrapper.getNodeCount();
    populationModel.initPopSizes(nBranches);
    populationModel.initPopSizes(popSize);

    Node cNode = null;
    Node bNode = null;
    for (Node n: speciesTreeWrapper.getRoot().getAllLeafNodes()) {
        if (n.getID().equals(bTipLabel)) {
            if (bIsParent) bNode = n.getParent();
            else bNode = n;
        } else if (n.getID().equals(cTipLabel)) {
            if (cIsParent) cNode = n.getParent();
            else cNode = n;
        }
    }

    Node yNode = bNode.getParent();
    Node zNode = yNode.getParent();
    Node aNode = (bNode == yNode.getRight()) ? yNode.getLeft() : yNode.getRight();

    if (cNode == null) {
        cNode = (yNode == zNode.getRight()) ? zNode.getLeft() : zNode.getRight();
    }

    CoordinatedExchange coex = new CoordinatedExchange();
    coex.initByName("speciesTree", speciesTreeWrapper, "geneTree", geneTrees, "testing", true, "weight", 1.0);
    coex.aNode = aNode;
    coex.bNode = bNode;
    coex.cNode = cNode;
    coex.yNode = yNode;
    coex.zNode = zNode;
    final double calculatedLogHR = coex.proposal();

    assertEquals(expectedLogHR, calculatedLogHR, allowedError);
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:56,代码来源:ExchangeTestHelper.java

示例10: testMultivariateNormal

import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
public void testMultivariateNormal() throws Exception{
    for(Instance test: all){
        RealParameter mean = new RealParameter();

        mean.initByName(
                "value",test.getMean(),
                "lower",Double.NEGATIVE_INFINITY,
                "upper",Double.POSITIVE_INFINITY);

        RealParameter precision = test.getPrecision();

        MultivariateNormal multiNorm = new MultivariateNormal();
        multiNorm.initByName(
                "mean",mean,
                "precision", precision);

        String[] xStrs = test.getX();
        double[] expectedFLogX = test.getFLogX();
        for(int i = 0; i < xStrs.length;i++){
            RealParameter x  =  new RealParameter();
            x.initByName(
                    "value",xStrs[i],
                    "lower",Double.NEGATIVE_INFINITY,
                    "upper",Double.POSITIVE_INFINITY);
            double fLogX1 = multiNorm.calcLogP(x);
            assertEquals(fLogX1, expectedFLogX[i], 1e-10);


            double fLogX2 =  MultivariateNormal.logPdf(
                    x.getValues(),
                    mean.getValues(),
                    multiNorm.getScaleMatrix(),
                    Math.log(MultivariateNormal.calculatePrecisionMatrixDeterminate(multiNorm.getScaleMatrix())),
                    1.0
            );

            assertEquals(fLogX2, expectedFLogX[i], 1e-10);
        }




    }
}
 
开发者ID:jessiewu,项目名称:substBMA,代码行数:45,代码来源:MultivariateNormalTest.java


注:本文中的beast.core.parameter.RealParameter.initByName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。