• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IntegerParameter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testCompositionCompoundDataType

import beast.core.parameter.IntegerParameter; //导入依赖的package包/类
public void testCompositionCompoundDataType() throws Exception {
	CompoundDataType compound = null;
	compound = new CompoundDataType();
	DataType d0 = datatype0();
	DataType d1 = datatype1();
	compound.initByName("components", d0, "components", d1, "ambiguities",
			new IntegerParameter(new Integer[] { 0 }));
	int counter = 0;
	for (int i = 0; i < d0.getStateCount(); ++i) {
		for (int j = 0; j < d1.getStateCount(); ++j) {
			assertEquals(i, compound.compoundState2componentState(counter, 0));
			assertEquals(j, compound.compoundState2componentState(counter, 1));
			++counter;
		}
	}
}
 
开发者ID:Anaphory,项目名称:correlatedcharacters,代码行数:17,代码来源:CompoundDataTypeTest.java


示例2: testCSM

import beast.core.parameter.IntegerParameter; //导入依赖的package包/类
@Test
public void testCSM() throws Exception {
	CSMwithPublicMatrix csm = new CSMwithPublicMatrix();
	csm.initByName("rates", new RealParameter(rates), "frequencies", freqs, "shape", new IntegerParameter(shape));

	final double[][] result = csm.getMatrix();

	System.out.printf("%s\n", Arrays.deepToString(result));
	System.out.printf("%s\n\n", Arrays.toString(expectedResult));

	int i = 0;
	for (int k = 0; k < result.length; ++k) {
		for (int l = 0; l < result[k].length; ++l) {
			assertEquals(expectedResult[i], result[k][l], 1e-10);
			++i;
		}
	}
	assertEquals(i, expectedResult.length);

}
 
开发者ID:Anaphory,项目名称:correlatedcharacters,代码行数:21,代码来源:CorrelatedSubstitutionModelTest.java


示例3: 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


示例4: testRates

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


示例5: initAndValidate

import beast.core.parameter.IntegerParameter; //导入依赖的package包/类
@Override
public void initAndValidate() {
    parameter = parameterInput.get();
    if (parameter instanceof RealParameter) {
        lower = (Double) parameter.getLower();
        upper = (Double) parameter.getUpper();
    } else if (parameter instanceof IntegerParameter) {
        lowerIndex = (Integer) parameter.getLower();
        upperIndex = (Integer) parameter.getUpper();
    } else {
        throw new IllegalArgumentException("parameter should be a RealParameter or IntergerParameter, not " + parameter.getClass().getName());
    }

    howMany = howManyInput.get();
    if (howMany > parameter.getDimension()) {
        throw new IllegalArgumentException("howMany it too large: must be less than the dimension of the parameter");
    }
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:19,代码来源:UniformOperator.java


示例6: proposal

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

    final IntegerParameter param = parameterInput.get(this);

    final int i = Randomizer.nextInt(param.getDimension());
    final int value = param.getValue(i);
    final int newValue = value + Randomizer.nextInt(2 * windowSize + 1) - windowSize;

    if (newValue < param.getLower() || newValue > param.getUpper()) {
        // invalid move, can be rejected immediately
        return Double.NEGATIVE_INFINITY;
    }
    if (newValue == value) {
        // this saves calculating the posterior
        return Double.NEGATIVE_INFINITY;
    }

    param.setValue(i, newValue);

    return 0.0;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:27,代码来源:IntRandomWalkOperator.java


示例7: prepare

import beast.core.parameter.IntegerParameter; //导入依赖的package包/类
private void prepare() {

        //System.out.println("prepare");

        categories = (IntegerParameter) categoryInput.get();

        distribution = rateDistInput.get();

        tree = treeInput.get();

        rates = new double[categories.getDimension()];
        try {
            for (int i = 0; i < rates.length; i++) {
                rates[i] = distribution.inverseCumulativeProbability((i + 0.5) / rates.length);
            }
        } catch (Exception e) {
            // Exception due to distribution not having  inverseCumulativeProbability implemented.
            // This should already been caught at initAndValidate()
            e.printStackTrace();
            System.exit(0);
        }

        //if (normalize) computeFactor();
    }
 
开发者ID:jessiewu,项目名称:substBMA,代码行数:25,代码来源:SynchronizableUCRelaxedClock.java


示例8: testMultinomial

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


示例9: proposal

import beast.core.parameter.IntegerParameter; //导入依赖的package包/类
@Override
public double proposal() {

    List<Integer> allIndices = new ArrayList<Integer>(masterList);
    int left, right;

    do {
        if (allIndices.isEmpty()) {
            return Double.NEGATIVE_INFINITY;
        }
        left = allIndices.remove(Randomizer.nextInt(allIndices.size()));
    } while (((IntegerParameter)parameter).getValue(left) < 0);

    do {
        if (allIndices.isEmpty()) {
            return Double.NEGATIVE_INFINITY;
        }
        right = allIndices.remove(Randomizer.nextInt(allIndices.size()));
    }   while (((IntegerParameter)parameter).getValue(right) < 0);

    parameter.swap(left, right);

    return 0.0;
}
 
开发者ID:CompEvol,项目名称:sampled-ancestors,代码行数:25,代码来源:IntSwapWithExclusion.java


示例10: main

import beast.core.parameter.IntegerParameter; //导入依赖的package包/类
/**
 * Main method for debugging.
 *
 * @param args
 */
public static void main(String[] args) throws Exception {
   RealParameter shiftTimesParam = new RealParameter(new Double[] {5.0});
    RealParameter rateParam = new RealParameter(new Double[] {1.0, 0.0});

    SISModel model = new SISModel();
    model.initByName(
            "origin", new RealParameter("10.0"),
            "S0", new IntegerParameter("200"),
            "infectionRate", new RealParameter("0.01"),
            "recoveryRate", new RealParameter("0.1"));

    double T = 10.0;
    int nSteps = 5;
    double dt = T/(nSteps-1);
    System.out.println("t\trate");
    for (int i=0; i<nSteps; i++) {
        double t = i*dt;
        System.out.println(t +  "\t" + model.getRateAtTime(rateParam, shiftTimesParam, true, t));
    }

}
 
开发者ID:tgvaughan,项目名称:EpiInf,代码行数:27,代码来源:EpidemicModel.java


示例11: test6

import beast.core.parameter.IntegerParameter; //导入依赖的package包/类
@Test
public void test6() throws Exception {

    SkylinePopulationFunction skyline = new SkylinePopulationFunction();
    skyline.initByName(
            "acg", acg,
            "popSizes", new RealParameter("1.0 1.0 5.0 1.0"),
            "groupSizes", new IntegerParameter("0"),
            "nGridPoints", 5,
            "piecewiseLinear", true);

    for (CFEventList.Event cfEvent : acg.getCFEvents()) {
        double t = cfEvent.getHeight();
        assertTrue(Math.abs(t-skyline.getInverseIntensity(skyline.getIntensity(t)))<1e-14);
    }
}
 
开发者ID:tgvaughan,项目名称:bacter,代码行数:17,代码来源:SkylinePopulationFunctionTest.java


示例12: 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


示例13: testDecompositionCompoundDataType

import beast.core.parameter.IntegerParameter; //导入依赖的package包/类
public void testDecompositionCompoundDataType() {
	CompoundDataType compound = null;
	compound = new CompoundDataType();
	DataType d0 = datatype0();
	DataType d1 = datatype1();
	compound.initByName("components", d0, "components", d1, "ambiguities",
			new IntegerParameter(new Integer[] { 0 }));
	int counter = 0;
	for (int i = 0; i < d0.getStateCount(); ++i) {
		for (int j = 0; j < d1.getStateCount(); ++j) {
			assertEquals(counter, compound.componentState2compoundState(new int[] { i, j }));
			++counter;
		}
	}
}
 
开发者ID:Anaphory,项目名称:correlatedcharacters,代码行数:16,代码来源:CompoundDataTypeTest.java


示例14: testGetStateSetIsCompatibleWithIndexOperations

import beast.core.parameter.IntegerParameter; //导入依赖的package包/类
public void testGetStateSetIsCompatibleWithIndexOperations() {
	CompoundDataType compound = null;
	compound = new CompoundDataType();
	DataType d0 = datatype0();
	DataType d1 = datatype1();
	Integer ambiguities = 1;
	compound.initByName("components", d0, "components", d1,
			"ambiguities", new IntegerParameter(new Integer[] { ambiguities }));
	for (int i = 0; i < d0.getStateCount(); ++i) {
		for (int j = 0; j < d1.getStateCount(); ++j) {
			int k = compound.componentState2compoundState(new int[] { i, j });
			assertEquals(true, compound.getStateSet(k)[k]);
		}
	}
}
 
开发者ID:Anaphory,项目名称:correlatedcharacters,代码行数:16,代码来源:CompoundDataTypeTest.java


示例15: testUniformity

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


示例16: initAndValidate

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


示例17: initAndValidate

import beast.core.parameter.IntegerParameter; //导入依赖的package包/类
@Override
public void initAndValidate() {
    final IntegerParameter treeRates = treeRatesInput.get();
    nNodes = treeRates.getDimension();
    lowerBound = treeRates.getLower();
    integerRange = 1 + treeRates.getUpper() - lowerBound;

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


示例18: proposal

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

    for (int i = 0; i < discreteK; i++) {
        final int nodeNumber = cycle[i];
        final int newRate = lowerBound + Randomizer.nextInt(integerRange);
        treeRates.setValue(nodeNumber, newRate);
    }

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


示例19: testRates

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


示例20: calculateLogP

import beast.core.parameter.IntegerParameter; //导入依赖的package包/类
@Override
public double calculateLogP() {
    Function x = m_x.get();
    if (x instanceof RealParameter || x instanceof IntegerParameter) {
        // test that parameter is inside its bounds
        double l = 0.0;
        double h = 0.0;
        if (x instanceof RealParameter) {
            l = ((RealParameter) x).getLower();
            h = ((RealParameter) x).getUpper();
        } else {
            l = ((IntegerParameter) x).getLower();
            h = ((IntegerParameter) x).getUpper();
        }
        for (int i = 0; i < x.getDimension(); i++) {
            double value = x.getArrayValue(i);
            if (value < l || value > h) {
                logP = Double.NEGATIVE_INFINITY;
                return Double.NEGATIVE_INFINITY;
            }
        }
    }
    logP = dist.calcLogP(x);
    if (logP == Double.POSITIVE_INFINITY) {
        logP = Double.NEGATIVE_INFINITY;
    }
    return logP;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:29,代码来源:Prior.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EnumType类代码示例发布时间:2022-05-22
下一篇:
Java SetFeature类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap