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


Java RealParameter.getDimension方法代码示例

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


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

示例1: initPopSizes

import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
@Override
public void initPopSizes(double tipInitial) {
    final double topInitial = tipInitial * 0.5;

    final RealParameter tipPopSizes = tipPopSizesInput.get();
    final RealParameter topPopSizes = topPopSizesInput.get();

    final double tipLower = tipPopSizes.getLower();
    final double tipUpper = tipPopSizes.getUpper();

    final double topLower = topPopSizes.getLower();
    final double topUpper = topPopSizes.getUpper();

    if (tipPopSizes.isEstimatedInput.get() && tipInitial > tipLower && tipInitial < tipUpper) {
        for (int i = 0; i < tipPopSizes.getDimension(); i++)
            tipPopSizes.setValue(i, tipInitial);
    }

    if (topPopSizes.isEstimatedInput.get() && topInitial > topLower && topInitial < topUpper) {
     for (int i = 0; i < topPopSizes.getDimension(); i++)
         topPopSizes.setValue(i, topInitial);
    }
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:24,代码来源:LinearWithConstantRoot.java

示例2: proposal

import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
/**
 * override this for proposals,
 * returns log of hastingRatio, or Double.NEGATIVE_INFINITY if proposal should not be accepted *
 */
@Override
public double proposal() {

    RealParameter param = parameterInput.get(this);
    for (int i = 0; i < param.getDimension(); i++){
     double value = param.getValue(i);
     double newValue = value;
     double windowSize = 0.0;
     
    	if (indicatorInput.get().getArrayValue(i) > 0.5)
    		windowSize = windowSizeOn;
    	else
    		windowSize = windowSizeOff;
    		

     if (useGaussian) {
         newValue += Randomizer.nextGaussian() * windowSize;
     } else {
         newValue += Randomizer.nextDouble() * 2 * windowSize - windowSize;
     }
	
     if (newValue < param.getLower() || newValue > param.getUpper()) {
         return Double.NEGATIVE_INFINITY;
     }
     if (newValue == value) {
         // this saves calculating the posterior
         return Double.NEGATIVE_INFINITY;
     }
	
     param.setValue(i, newValue);
    }
    return 0.0;
}
 
开发者ID:nicfel,项目名称:Mascot,代码行数:38,代码来源:RealRandomWalkOperator.java

示例3: initAndValidate

import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
@Override
public void initAndValidate() {
    final RealParameter treeRates = treeRatesInput.get();
    nNodes = treeRates.getDimension();
    lowerBound = treeRates.getLower();
    upperBound = treeRates.getUpper();

    deltaScaleFactor = 2.0 * deltaInput.get() / nNodes;

    setLimits(2, nNodes);
    super.initAndValidate();
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:13,代码来源:NetworkRateExchange.java

示例4: initPopSizes

import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
@Override
public void initPopSizes(double popInitial) {
    final RealParameter popSizes = popSizesInput.get();
    final double lower = popSizes.getLower();
    final double upper = popSizes.getUpper();

    if (popSizes.isEstimatedInput.get() && popInitial > lower && popInitial < upper) {
     for (int i = 0; i < popSizes.getDimension(); i++) {
         popSizes.setValue(i, popInitial);
     }
    }
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:13,代码来源:ConstantPopulations.java

示例5: initAndValidate

import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
@Override
public void initAndValidate() {
    final RealParameter parameter = parameterInput.get();
    nNodes = parameter.getDimension();
    setLimits(2, nNodes);
    super.initAndValidate();
}
 
开发者ID:genomescale,项目名称:starbeast2,代码行数:8,代码来源:RealCycle.java

示例6: refresh

import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
public void refresh(){
    RealParameter meanVec = this.meanVec.get();
    mean = new double[meanVec.getDimension()];
    for(int i = 0; i < mean.length;i++){
        mean[i] = meanVec.getValue(i);
        
    }

    int dim = (int)Math.sqrt(precisionMatrix.getDimension());
    int k = 0;
    precision = new double[dim][dim];
    for(int i = 0; i < precision.length;i++){
        for(int j = 0; j < precision[i].length;j++){
            precision[i][j] = precisionMatrix.getValue(k++);
        }

    }

    logDet = Math.log(calculatePrecisionMatrixDeterminate(precision));
    variance = new SymmetricMatrix(precision).inverse().toComponents();
    cholesky = getCholeskyDecomposition(variance);

    storedMean = new double[mean.length];
    storedPrecision = new double[precision.length][precision.length];
    storedVariance = new double[variance.length][variance.length];
    storedCholesky = new double[cholesky.length][cholesky.length];




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

示例7: proposal

import beast.core.parameter.RealParameter; //导入方法依赖的package包/类
/**
 * override this for proposals,
 *
 * @return log of Hastings Ratio, or Double.NEGATIVE_INFINITY if proposal
 *         should not be accepted
 **/
@Override
public final double proposal() {
       double r = Randomizer.nextDouble();
	final double scale = (m_fScaleFactor + (r * ((1.0 / m_fScaleFactor) - m_fScaleFactor)));
       final double scaleLog = (m_fScaleFactor + r*-2*m_fScaleFactor);
	int goingUp = 0, goingDown = 0;

	try {
           List<StateNode> upList = m_up.get();
		for (int i = 0; i < upList.size(); i++) {
			StateNode up = upList.get(i).getCurrentEditable(this);
               if(isExpUp[i]){
                   if(up instanceof RealParameter){
                       RealParameter upParameter = (RealParameter)up;
                       int upParameterDim = upParameter.getDimension();
                       for(int j = 0; j < upParameterDim; j++){
                           double upVal = upParameter.getValue(j);

                           upParameter.setValue(Math.log(Math.exp(upVal)*scale));

                       }

                   }else{
                       throw new RuntimeException("If isExp is true, then the state node must be a real parameter.");
                   }

               }else{


			    goingUp += up.scale(scale);
               }
		}

           List<StateNode> downList = m_down.get();

		for (int i = 0; i < downList.size(); i++) {
			StateNode down = downList.get(i).getCurrentEditable(this);
               if(isExpDown[i]){
                   if(down instanceof RealParameter){
                       RealParameter downParameter = (RealParameter)down;
                       int downParameterDim = downParameter.getDimension();
                       for(int j = 0; j < downParameterDim; j++){
                           double downVal = downParameter.getValue(j);

                           downParameter.setValue(Math.log(Math.exp(downVal)*scale));

                       }

                   }else{
                       throw new RuntimeException("If isExp is true, then the state node must be a real parameter.");
                   }
               }else{
			    goingDown += down.scale(1.0 / scale);
               }
		}
	} catch (Exception e) {
		// scale resulted in invalid StateNode, abort proposal
		return Double.NEGATIVE_INFINITY;
	}
       //System.out.println(goingUp - goingDown );
	return (goingUp - goingDown - 2) * Math.log(scale);
       //return -2 * Math.log(scale);
}
 
开发者ID:jessiewu,项目名称:substBMA,代码行数:70,代码来源:ExtendedUpDownOperator.java

示例8: initAndValidate

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

        RealParameter priorMeanParam = priorMeanInput.get();
        RealParameter priorPrecisionParam = priorPrecisionInput.get();
        dim = priorMeanParam.getDimension();
        if(dim != (int)Math.sqrt(priorPrecisionParam.getDimension())){
            throw new RuntimeException("The rows and column counts of the precision matrix" +
                    " should equal to the dimension of the mean vector.");
        }
        priorMean = new double[dim];
        for(int i = 0;i < dim;i++){
            priorMean[i] = priorMeanParam.getValue(i);

        }



        priorPrecision = new double[dim][dim];

        int k = 0;

        for(int i = 0; i< dim; i++){
            for(int j = 0; j < dim; j++){
                priorPrecision[i][j] = priorPrecisionParam.getValue(k++);
            }
        }
        x = xInput.get();



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


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