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


Java Prior类代码示例

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


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

示例1: assertParameterCountInPriorIs

import beast.math.distributions.Prior; //导入依赖的package包/类
void assertParameterCountInPriorIs(int i) {
	// count nr of parameters in Prior objects in prior
	// including those for prior distributions (Normal, etc)
	// useful to make sure they do (or do not) get linked
	Set<Function> parameters = new LinkedHashSet<>();
	CompoundDistribution prior = (CompoundDistribution) doc.pluginmap.get("prior");
	for (Distribution p : prior.pDistributions.get()) {
		if (p instanceof Prior) {
			Prior p2 = (Prior) p;
			parameters.add(p2.m_x.get());
			for (BEASTInterface o : p2.distInput.get().listActiveBEASTObjects()) {
				if (o instanceof Parameter) {
					parameters.add((Parameter<?>) o);
				}
			}
		}
	}
	System.err.println("Number of parameters in prior = " + parameters.size());
	if (i >= 0) {
		assertThat(parameters.size()).as("Expected " + i + " parameters in prior").isEqualTo(i);
	}
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:23,代码来源:BeautiBase.java

示例2: test

import beast.math.distributions.Prior; //导入依赖的package包/类
@Test
public void test() throws Exception {
    RealParameter xparam = new RealParameter("10.0");
    xparam.setLower(Double.NEGATIVE_INFINITY);
    xparam.setUpper(Double.POSITIVE_INFINITY);
    xparam.setID("x");
    
    ExpCalculatorParametricDistribution instance = new ExpCalculatorParametricDistribution();
    instance.initByName(
            "expression", "exp(-(x-11)^2/2)");
    
    Prior prior = new Prior();
    prior.initByName("x", xparam, "distr", instance);
 
    double res = prior.calculateLogP();
    assertTrue(Math.abs(res - (-0.5))<1e-15);
}
 
开发者ID:tgvaughan,项目名称:feast,代码行数:18,代码来源:ExpCalculatorParametricDistributionTest.java

示例3: testUniformity

import beast.math.distributions.Prior; //导入依赖的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

示例4: type

import beast.math.distributions.Prior; //导入依赖的package包/类
@Override
public Class<?> type() {
	return Prior.class;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:5,代码来源:PriorInputEditor.java

示例5: init

import beast.math.distributions.Prior; //导入依赖的package包/类
@Override
  public void init(Input<?> input, BEASTInterface beastObject, int itemNr, ExpandOption isExpandOption, boolean addButtons) {
  	List<?> list = (List<?>) input.get();
  	Collections.sort(list, (Object o1, Object o2) -> {
		if (o1 instanceof BEASTInterface && o2 instanceof BEASTInterface) {
			String d1 = ((BEASTInterface)o1).getID();
			String id2 = ((BEASTInterface)o2).getID();
			// first the tree priors
			if (o1 instanceof TreeDistribution) {
				if (o2 instanceof TreeDistribution) {
					TreeInterface tree1 = ((TreeDistribution)o1).treeInput.get();
					if (tree1 == null) {
						tree1 = ((TreeDistribution)o1).treeIntervalsInput.get().treeInput.get();
					}
					TreeInterface tree2 = ((TreeDistribution)o2).treeInput.get();
					if (tree2 == null) {
						tree2 = ((TreeDistribution)o2).treeIntervalsInput.get().treeInput.get();
					}
					return d1.compareTo(id2);
				} else {
					return -1;
				}
			} else if (o1 instanceof MRCAPrior) {
				// last MRCA priors
				if (o2 instanceof MRCAPrior) {
					return d1.compareTo(id2);
				} else {
					return 1;
				}
			} else {
				if (o2 instanceof TreeDistribution) {
					return 1;
				}
				if (o2 instanceof MRCAPrior) {
					return -1;
				}
				if (o1 instanceof Prior) {
					d1 = ((Prior) o1).getParameterName(); 
				}
				if (o2 instanceof Prior) {
					id2 = ((Prior) o2).getParameterName(); 
				}
				return d1.compareTo(id2);
			}
		}
		return 0;
	}
);
  	
  	
      rangeButtons = new ArrayList<>();
      taxonButtons = new ArrayList<>();
      
      //m_buttonStatus = ButtonStatus.NONE;
      super.init(input, beastObject, itemNr, isExpandOption, addButtons);

      
      if (beastObject instanceof BeautiPanelConfig) {
      	BeautiPanelConfig config = (BeautiPanelConfig) beastObject;
      	if (config.parentBEASTObjects != null && config.parentBEASTObjects.size() > 0 && config.parentBEASTObjects.get(0).getID().equals("speciescoalescent")) {
      		m_buttonStatus = ButtonStatus.NONE;
      	}
      }
      
      if (m_buttonStatus == ButtonStatus.ALL || m_buttonStatus == ButtonStatus.ADD_ONLY) {
       addButton = new SmallButton("+ Add Prior", true);
       addButton.setName("addItem");
       addButton.setToolTipText("Add new prior (like an MRCA-prior) to the list of priors");
       addButton.addActionListener(e -> {
               addItem();
           });
       buttonBox.add(addButton);
          buttonBox.add(Box.createHorizontalGlue());
      }
  }
 
开发者ID:CompEvol,项目名称:beast2,代码行数:76,代码来源:PriorListInputEditor.java


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