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


Java IntegerParameter.getValues方法代码示例

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


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

示例1: proposal

import beast.core.parameter.IntegerParameter; //导入方法依赖的package包/类
@Override
public double proposal() {
    final IntegerParameter treeRates = treeRatesInput.get();
    final Integer[] treeRatesArray = treeRates.getValues();
    final int[] cycle = chooseK(nNodes);

    final int lastNodeNumber = cycle[discreteK - 1];
    int previousRate = treeRatesArray[lastNodeNumber];
    for (int i = 0; i < discreteK; i++) {
        final int nodeNumber = cycle[i];
        treeRates.setValue(nodeNumber, previousRate);
        previousRate = treeRatesArray[nodeNumber];
    }

    return 0.0;
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:17,代码来源:DiscreteRateCycle.java

示例2: initAndValidate

import beast.core.parameter.IntegerParameter; //导入方法依赖的package包/类
@Override
public void initAndValidate() {
	try {
		maxIndex = parametersInput.get().getDimension();
	} catch (NullPointerException e) {
		throw new IllegalArgumentException("parameters was left unspecified");
	}
	if (entryInput.get() == null) {
		Integer[] build_entries = new Integer[maxIndex];
		for (int i=0; i<maxIndex; ++i) {
			build_entries[i] = i;
		}
		entries = new IntegerParameter(build_entries);
	} else {
		entries = entryInput.get();
		for (Integer entry : entries.getValues()) {
			if (entry > groupingsInput.get().getDimension()) {
				throw new RuntimeException(
						"entries must be valid index of groupings");
			}
		}
	}
	// Array-like RealParameters do not implement java.lang.iterable, so we
	// must do the iteration by hand.
	for (int groupIndex = groupingsInput.get().getDimension() - 1; groupIndex >= 0; --groupIndex) {
		if (groupingsInput.get().getNativeValue(groupIndex) >= maxIndex) {
			throw new RuntimeException(
					"All entries in groupings must be valid indices of parameters");
		}
	}
	// value = parametersInput[groupingsInput[entry]]
}
 
开发者ID:Anaphory,项目名称:correlatedcharacters,代码行数:33,代码来源:Selector.java

示例3: testIntegerParameterBound

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

示例4: instantiate

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

示例5: initAndValidate

import beast.core.parameter.IntegerParameter; //导入方法依赖的package包/类
public void initAndValidate() {

        //setup weights
        if(patternWeightInput.get() == null){
            patternWeights = dataInput.get().getWeights();

        }else{
            IntegerParameter weightsParameter = patternWeightInput.get();
            Integer[] tempPatternWeights = weightsParameter.getValues();
            patternWeights = new int [tempPatternWeights.length];
            for(int i = 0; i < tempPatternWeights.length;i++){
                patternWeights[i] = tempPatternWeights[i];
            }
           
        }



        storedPatternWeights = new int[patternWeights.length];

        super.initAndValidate();

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


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