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


Java Randoms.nextUniform方法代码示例

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


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

示例1: sampleLocation

import cc.mallet.util.Randoms; //导入方法依赖的package包/类
public int sampleLocation (Randoms r)
{
  double sum = sum();
  double sampled = r.nextUniform () * sum;

  double cum = 0;
  for (int idx = 0; idx < probs.numLocations (); idx++) {
    double val = value (idx);
      cum += val;

    if (sampled <= cum + EPS) {
      return idx;
    }
  }

  throw new RuntimeException
          ("Internal errors: Couldn't sample from potential "+this+"\n"+dumpToString ()+"\n Using value "+sampled);
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:19,代码来源:AbstractTableFactor.java

示例2: randomIndex

import cc.mallet.util.Randoms; //导入方法依赖的package包/类
public int randomIndex (Randoms r)
{
	double f = r.nextUniform();
	double sum = 0;
	int i;
	for (i = 0; i < values.length; i++) {
		sum += values[i];
		//System.out.print (" sum="+sum);
		if (sum >= f)
			break;
	}
	//if (sum < f) throw new IllegalStateException
	//System.out.println ("i = "+i+", f = "+f+", sum = "+sum);
	assert (sum >= f);
	return i;
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:17,代码来源:Multinomial.java

示例3: createBoltzmannChain

import cc.mallet.util.Randoms; //导入方法依赖的package包/类
static FactorGraph createBoltzmannChain (int len)
{
  Randoms r = new Randoms (3241321);

  List<Variable> vars = new ArrayList<Variable> ();
  for (int i = 0; i < len; i++) {
    Variable x_i = new Variable (2);
    x_i.setLabel ("X_"+i);
    vars.add (x_i);
  }

  List<Factor> factors = new ArrayList<Factor> (vars.size ());

  // node factors
  for (int i = 0; i < len; i++) {
    double u = r.nextUniform (-4.0, 4.0);
    factors.add (new BoltzmannUnaryFactor (vars.get (i), u));
  }

  // edge factors
  for (int i = 0; i < len-1; i++) {
    Variable alpha = new Variable (Variable.CONTINUOUS);
    alpha.setLabel ("ALPHA_"+i);
    factors.add (new UniformFactor (alpha, -4.0, 4.0));
    factors.add (new PottsTableFactor (vars.get (i), vars.get(i+1), alpha));
  }

  return new FactorGraph (factors);
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:30,代码来源:TestAbstractBeliefPropagation.java

示例4: sample

import cc.mallet.util.Randoms; //导入方法依赖的package包/类
public Assignment sample (Randoms r)
{
  double val = r.nextUniform (min, max);
  return new Assignment (var, val);
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:6,代码来源:UniformFactor.java


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