NormalDistributionMaximumLikelihoodEstimator extends DistributionParameterEstimator<Double> { @Override public ProbabilityDistribution<Double> evaluate(final double[] x) { Validate.notNull(x, "x"); ArgumentChecker.notEmpty(x, "x"); return new NormalDistribution(_mean.evaluate(x), _std.evaluate(x)); }  @Override ProbabilityDistribution<Double> evaluate(final double[] x);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNull() { ESTIMATOR.evaluate((double[]) null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testEmpty() { ESTIMATOR.evaluate(new double[0]); }
@Test public void test() { final int n = 500000; final double eps = 1e-2; final double mu = -1.3; final double sigma = 0.4; final ProbabilityDistribution<Double> p1 = new NormalDistribution(mu, sigma, new MersenneTwister64(MersenneTwister.DEFAULT_SEED)); final double[] x = new double[n]; for (int i = 0; i < n; i++) { x[i] = p1.nextRandom(); } final NormalDistribution p2 = (NormalDistribution) ESTIMATOR.evaluate(x); assertEquals(p2.getMean(), mu, eps); assertEquals(p2.getStandardDeviation(), sigma, eps); }