org.apache.mahout.math.jet.random.Normal.nextDouble()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(1.5k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中org.apache.mahout.math.jet.random.Normal.nextDouble()方法的一些代码示例,展示了Normal.nextDouble()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Normal.nextDouble()方法的具体详情如下:
包路径:org.apache.mahout.math.jet.random.Normal
类名称:Normal
方法名:nextDouble

Normal.nextDouble介绍

[英]Returns a random number from the distribution.
[中]从分布中返回一个随机数。

代码示例

代码示例来源:origin: tdunning/bandit-ranking

/**
 * Returns a random number from the distribution.
 *
 * @return A new sample from this distribution.
 */
@Override
public double nextDouble() {
  double variance = nextVariance();
  double mean = nd.nextDouble() * Math.sqrt(variance / n) + m;
  return nd.nextDouble() * Math.sqrt(variance) + mean;
}

代码示例来源:origin: tdunning/bandit-ranking

@Override
public double nextMean() {
  double sd = Math.sqrt(nextVariance() / n);
  return nd.nextDouble() * sd + m;
}

代码示例来源:origin: tdunning/log-synth

@Override
  public JsonNode sample() {
    double x;
    do {
      x = rand.nextDouble();
    } while (x < min || x > max);
    return new DoubleNode(x);
  }
}

代码示例来源:origin: org.apache.mahout/mahout-mrlegacy

@Test
 public void testEntropy() {
  Auc auc = new Auc();
  Random gen = RandomUtils.getRandom();
  Normal n0 = new Normal(-1, 1, gen);
  Normal n1 = new Normal(1, 1, gen);
  for (int i=0; i<100000; i++) {
   double score = n0.nextDouble();
   double p = n1.pdf(score) / (n0.pdf(score) + n1.pdf(score));
   auc.add(0, p);

   score = n1.nextDouble();
   p = n1.pdf(score) / (n0.pdf(score) + n1.pdf(score));
   auc.add(1, p);
  }
  Matrix m = auc.entropy();
  assertEquals(-0.35, m.get(0, 0), 0.02);
  assertEquals(-2.36, m.get(0, 1), 0.02);
  assertEquals(-2.36, m.get(1, 0), 0.02);
  assertEquals(-0.35, m.get(1, 1), 0.02);
 }
}

相关文章