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


Java State.initByName方法代码示例

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


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

示例1: testRates

import beast.core.State; //导入方法依赖的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

示例2: testCanOperate

import beast.core.State; //导入方法依赖的package包/类
@Test
public void testCanOperate() {
	// Test whether a validly initialised operator may make proposals
	State state = new State();
	RealParameter parameter = new RealParameter(new Double[] { 1., 1., 1., 1. });
	state.initByName("stateNode", parameter);
	state.initialise();
	DeltaExchangeOperator d = new DeltaExchangeOperator();
	// An invalid operator should either fail in initByName or make valid
	// proposals
	try {
		d.initByName("parameter", parameter);
	} catch (RuntimeException e) {
		return;
	}
	d.proposal();
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:18,代码来源:DeltaExchangeOperatorTest.java

示例3: testDDPointer

import beast.core.State; //导入方法依赖的package包/类
public void testDDPointer(){
    try{
    for(Instance test: tests){
        test.setup();
        DPPointer pointer = test.getDPPointer();
        ParameterList paramList =  test.getParameterList();
        State state = new State();

    state.initByName(
            "stateNode", pointer,
            "stateNode", paramList
    );
    state.initialise();

        operationEx1(pointer,paramList);
    }
    }catch(Exception e){
        throw new RuntimeException(e);

    }

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

示例4: testUniformity

import beast.core.State; //导入方法依赖的package包/类
public void testUniformity() throws Exception {
	Double[] m_parameters = new Double[length];
	Integer[] m_indices = new Integer[length];
	Integer[] m_sizes = new Integer[length];
	for (int i = 0; i < length; ++i) {
		m_parameters[i] = 1.;
		m_indices[i] = i;
		m_sizes[i] = 1;
	}
	StateNode parameters = new RealParameter(m_parameters);
	StateNode indices = new IntegerParameter(m_indices);
	StateNode sizes = new IntegerParameter(m_sizes);
	State state = new State();
	state.initByName("stateNode", parameters, "stateNode", indices,
			"stateNode", sizes);

	RescaledDirichlet rescaledDirichlet = new RescaledDirichlet();
	rescaledDirichlet.initByName("sizes", sizes);

	Distribution prior = new Prior();
	prior.initByName("x", parameters, "distr", rescaledDirichlet);

	Operator merger = new MergeOperator();
	merger.initByName("parameters", parameters, "groupings", indices,
			"sizes", sizes, "weight", 1.);
	Operator splitter = new SplitOperator();
	splitter.initByName("parameters", parameters, "groupings", indices,
			"sizes", sizes, "weight", 1.);

	// It would be nice to have a logger that could just write the results
	// into a list, so we can easily check the likelihood that this does
	// indeed form a uniform prior, and show how to analyse results.
	MCMC mcmc = new MCMC();
	mcmc.initByName("chainLength", 100000, "preBurnin", 1, "state", state,
			"distribution", prior, "operator", merger, "operator", splitter);

	mcmc.run();
	throw new RuntimeException("The core of this test remains unimplemented");
}
 
开发者ID:Anaphory,项目名称:correlatedcharacters,代码行数:40,代码来源:UniformTest.java

示例5: testRates

import beast.core.State; //导入方法依赖的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

示例6: register

import beast.core.State; //导入方法依赖的package包/类
static public void register(Operator operator, final Object... operands) {
	HashMap<String, StateNode> operandsMap;
	operandsMap = new HashMap<String, StateNode>();
	if (operands.length % 2 == 1) {
		throw new RuntimeException("Expected even number of arguments, name-value pairs");
	}
	for (int i = 0; i < operands.length; i += 2) {
		if (operands[i] instanceof String) {
			final String name = (String) operands[i];
			if (operands[i + 1] instanceof StateNode) {
				final StateNode node = (StateNode) operands[i + 1];
				operandsMap.put(name, node);
			} else {
				throw new IllegalArgumentException("Expected a StateNode in " + (i + 1) + "th argument ");
			}
		} else {
			throw new IllegalArgumentException("Expected a String in " + i + "th argument ");
		}
	}
	State state = new State();
	state.initByName("stateNode", new ArrayList<StateNode>(operandsMap.values()));
	state.initialise();
	Object[] operandsAndWeight = new Object[operands.length + 2];
	for (int i = 0; i < operands.length; ++i) {
		operandsAndWeight[i] = operands[i];
	}
	operandsAndWeight[operands.length] = "weight";
	operandsAndWeight[operands.length + 1] = "1";
	operator.initByName(operandsAndWeight);
	operator.validateInputs();
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:32,代码来源:TestOperator.java

示例7: testParameterBound

import beast.core.State; //导入方法依赖的package包/类
public void testParameterBound() {
  	try {
       count = new int[dimension][4]; // 4 vaules {0, 1, 2, 3}
       RealParameter parameter = new RealParameter(new Double[]{1.0, 0.0, 2.0});
       parameter.setLower(0.0);
       parameter.setUpper(3.0);

  		State state = new State();
  		state.initByName("stateNode", parameter);
  		state.initialise();
  		
       UniformOperator uniformOperator = new UniformOperator();
       uniformOperator.initByName("parameter", parameter, "howMany", 3, "weight", 1.0);

       for (int i = 0; i < 400; i++) {
           uniformOperator.proposal();
           Double [] values = parameter.getValues();
           for (int k = 0; k < values.length; k++) {
               int j = (int)(double) values[k];
               count[k][j] += 1; 
           }
       }
       System.out.println("Discretized real distributions lower = 0.0, upper = 3.0");
       for (int j = 0; j < count.length; j++) {
        System.out.println("x[" +j + "] = " + Arrays.toString(count[j]));
	}
	
       assertTrue("Expected count[0][0-2] > 0 && count[0][3] == 0", (count[0][0] > 0) && (count[0][1] > 0) && (count[0][2] > 0) && (count[0][3] == 0));
       assertTrue("Expected count[1][0-2] > 0 && count[1][3] == 0", (count[1][0] > 0) && (count[1][1] > 0) && (count[1][2] > 0) && (count[1][3] == 0));
       assertTrue("Expected count[2][0-2] > 0 && count[2][3] == 0", (count[2][0] > 0) && (count[2][1] > 0) && (count[2][2] > 0) && (count[2][3] == 0));
  	} catch (Exception e) {
	e.printStackTrace();
}
  }
 
开发者ID:CompEvol,项目名称:beast2,代码行数:35,代码来源:UniformIntegerOperatorTest.java

示例8: testIntegerParameterBound

import beast.core.State; //导入方法依赖的package包/类
public void testIntegerParameterBound() {
  	try {
       count = new int[dimension][4]; // 4 vaules {0, 1, 2, 3}
       IntegerParameter parameter = new IntegerParameter(new Integer[]{1, 0, 3});
       parameter.setLower(0);
       parameter.setUpper(3);

  		State state = new State();
  		state.initByName("stateNode", parameter);
  		state.initialise();
  		
       UniformOperator uniformOperator = new UniformOperator();
       uniformOperator.initByName("parameter", parameter, "howMany", 3, "weight", 1.0);
      
       for (int i = 0; i < 400; i++) {
           uniformOperator.proposal();
           Integer [] values = parameter.getValues();
           for (int k = 0; k < values.length; k++) {
               int j = values[k];
               count[k][j] += 1; 
           }
       }

       System.out.println("Integer distributions lower = 0, upper = 3");
       for (int j = 0; j < count.length; j++) {
        System.out.println("x[" +j + "] = " + Arrays.toString(count[j]));
	}
	
       assertTrue("Expected count[0][0-3] > 0", count[0][0] > 0 && count[0][1] > 0 && count[0][2] > 0 && count[0][3] > 0);
       assertTrue("Expected count[1][0-3] > 0", count[1][0] > 0 && count[1][1] > 0 && count[1][2] > 0 && count[1][3] > 0);
       assertTrue("Expected count[2][0-3] > 0", count[2][0] > 0 && count[2][1] > 0 && count[2][2] > 0 && count[2][3] > 0);
  	} catch (Exception e) {
	e.printStackTrace();
}
  }
 
开发者ID:CompEvol,项目名称:beast2,代码行数:36,代码来源:UniformIntegerOperatorTest.java

示例9: testLogHR

import beast.core.State; //导入方法依赖的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: instantiate

import beast.core.State; //导入方法依赖的package包/类
public void instantiate(int dimension, int upper, int runs, Integer[]windowSizes) {
 	for (int r = 0; r < runs; r++) {
 	for (Integer windowSize : windowSizes) {
  	try {
  	    int[][] count = new int[dimension][upper + 1];
       Integer [] init = new Integer[dimension];
       Arrays.fill(init, 0);
       IntegerParameter parameter = new IntegerParameter(init);
       parameter.setLower(0);
       parameter.setUpper(upper);
	
  		State state = new State();
  		state.initByName("stateNode", parameter);
  		state.initialise();
  		
       IntRandomWalkOperator operator = new IntRandomWalkOperator();
       operator.initByName("parameter", parameter, "windowSize", windowSize, "weight", 1.0);
	
       for (int i = 0; i < 1000000 * (upper + 1); i++) {
           operator.proposal();
           Integer [] values = parameter.getValues();
           for (int k = 0; k < values.length; k++) {
               int j = values[k];
               count[k][j] += 1; 
           }
       }
       System.out.print("Distribution lower = 0, upper = " + upper +" windowSize = " + windowSize);
       for (int j = 0; j < count.length; j++) {
        //System.out.println("x[" +j + "] = " + Arrays.toString(count[j]));
	}
		
       int sum = 0;
       for (int i = 0; i < dimension; i++) {
       	for (int k = 0; k < count[i].length; k++) {
       		sum += Math.abs(count[i][k] - 1000000);
		}
       }
       System.out.println(" Average deviation: " + sum/(dimension * (upper + 1)));
       assertTrue("average deviation (" + sum/(dimension * (upper + 1)) + ") exceeds 10000", sum/(dimension * (upper + 1)) < 10000); 
  	} catch (Exception e) {
	e.printStackTrace();
}
 	}
 	}
 }
 
开发者ID:CompEvol,项目名称:beast2,代码行数:46,代码来源:IntRandomWalkOperatorTest.java


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