當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。