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

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

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

Normal.<init>介绍

暂无

代码示例

代码示例来源:origin: tdunning/t-digest

@Override
  AbstractDistribution create(Random random) {
    return new Normal(0.1, 0.1, random);
  }
};

代码示例来源:origin: apache/mahout

@Test
public void testCdf() {
 Random gen = RandomUtils.getRandom();
 double offset = 0;
 double scale = 1;
 for (int k = 0; k < 20; k++) {
  Normal dist = new Normal(offset, scale, null);
  DistributionChecks.checkCdf(offset, scale, dist, breaks, quantiles);
  offset = gen.nextGaussian();
  scale = Math.exp(3 * gen.nextGaussian());
 }
}

代码示例来源:origin: apache/mahout

@Test
public void consistency() {
 Random gen = RandomUtils.getRandom();
 double offset = 0;
 double scale = 1;
 Normal dist = new Normal(offset, scale, RandomUtils.getRandom());
 for (int k = 0; k < 20; k++) {
  dist.setState(offset, scale);
  DistributionChecks.checkDistribution(dist, breaks, offset, scale, 10000);
  offset = gen.nextGaussian();
  scale = Math.exp(3 * gen.nextGaussian());
 }
}

代码示例来源:origin: apache/mahout

@Test
 public void testToString() {
  assertEquals("org.apache.mahout.math.jet.random.Normal(m=1.300000, sd=5.900000)",
    new Normal(1.3, 5.9, null).toString());
 }
}

代码示例来源:origin: apache/mahout

@Test
public void testSetState() throws Exception {
 Normal dist = new Normal(0, 1, RandomUtils.getRandom());
 dist.setState(1.3, 5.9);
 DistributionChecks.checkDistribution(dist, breaks, 1.3, 5.9, 10000);
}

代码示例来源:origin: addthis/stream-lib

@Test
public void testNarrowNormal() {
  // this mixture of a uniform and normal distribution has a very narrow peak which is centered
  // near the median.  Our system should be scale invariant and work well regardless.
  final Random gen = RandomUtils.getRandom();
  AbstractContinousDistribution mix = new AbstractContinousDistribution() {
    AbstractContinousDistribution normal = new Normal(0, 1e-5, gen);
    AbstractContinousDistribution uniform = new Uniform(-1, 1, gen);
    @Override
    public double nextDouble() {
      double x;
      if (gen.nextDouble() < 0.5) {
        x = uniform.nextDouble();
      } else {
        x = normal.nextDouble();
      }
      return x;
    }
  };
  for (int i = 0; i < repeats(); i++) {
    runTest(mix, 100, new double[]{0.001, 0.01, 0.1, 0.3, 0.5, 0.7, 0.9, 0.99, 0.999}, "mixture", false, gen);
  }
}

代码示例来源:origin: apache/mahout

Vector v1 = v0.assign(new Normal(0, 1, gen));
assertSame(v0, v1);
Vector v2 = vectorToTest(20).assign(new Normal(0, 1, gen));
Vector dv1 = new DenseVector(v1);
Vector dv2 = new DenseVector(v2);

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

@Override
public AbstractContinousDistribution posteriorDistribution() {
  return new Normal(m, Math.sqrt(ss / n), gen);
}

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

@Override
  public DistributionWithMean nextDistribution() {
    double mean = gen.nextDouble();
    return new DistributionWithMean(new Normal(mean, sd, gen), mean);
  }
}

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

private void init() {
  if (max <= min) {
    throw new IllegalArgumentException("Parameter max must be greater than min");
  }
  if (max - min < 0.1 * sd) {
    throw new IllegalArgumentException("Value of max-min is too small, should be > 0.1 * sd");
  }
  if (Double.isNaN(sd)) {
    sd = 1 / precision;
  }
  if (seed != Integer.MAX_VALUE) {
    rand = new Normal(mean, sd, new Random(seed));
  } else {
    rand = new Normal(mean, sd, new Random());
  }
}

代码示例来源:origin: cloudera/mahout

@Test
public void testCdf() {
 Random gen = RandomUtils.getRandom();
 double offset = 0;
 double scale = 1;
 for (int k = 0; k < 20; k++) {
  Normal dist = new Normal(offset, scale, null);
  DistributionChecks.checkCdf(offset, scale, dist, breaks, quantiles);
  offset = gen.nextGaussian();
  scale = Math.exp(3 * gen.nextGaussian());
 }
}

代码示例来源:origin: cloudera/mahout

@Test
public void consistency() throws Exception {
 Random gen = RandomUtils.getRandom();
 double offset = 0;
 double scale = 1;
 Normal dist = new Normal(offset, scale, RandomUtils.getRandom());
 for (int k = 0; k < 20; k++) {
  dist.setState(offset, scale);
  DistributionChecks.checkDistribution(dist, breaks, offset, scale, 10000);
  offset = gen.nextGaussian();
  scale = Math.exp(3 * gen.nextGaussian());
 }
}

代码示例来源:origin: cloudera/mahout

@Test
 public void testToString() {
  assertEquals("org.apache.mahout.math.jet.random.Normal(m=1.300000, sd=5.900000)",
    new Normal(1.3, 5.9, null).toString());
 }
}

代码示例来源:origin: cloudera/mahout

@Test
public void testSetState() throws Exception {
 Normal dist = new Normal(0, 1, RandomUtils.getRandom());
 dist.setState(1.3, 5.9);
 DistributionChecks.checkDistribution(dist, breaks, 1.3, 5.9, 10000);
}

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

@Test
public void testStdDev2() throws Exception {
 Path input = getTestTempFilePath("stdDev/counts.file");
 Path output = getTestTempFilePath("stdDev/output.file");
 FileSystem fs = FileSystem.get(input.toUri(), conf);
 SequenceFile.Writer writer = new SequenceFile.Writer(fs, conf, input, IntWritable.class,
     DoubleWritable.class);
 Random random = RandomUtils.getRandom();
 Normal normal = new Normal(5, 3, random);
 for (int i = 0; i < 1000000; i++) {
  writer.append(new IntWritable(i), new DoubleWritable((long) normal.nextInt()));
 }
 writer.close();
 double v = BasicStats.stdDev(input, output, conf);
 assertEquals(3, v, 0.02);
}

代码示例来源: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);
 }
}

相关文章