private double onePoint(double x0, double x1, double[] point) { final IMonteCarloModel<Double, Double> mc = factory.createModel(x0, x1, point); mc.addSamples(samples); final double value = mc.getStats().value(); return FastMath.log(value); }
public void testMeanAndVariance() throws MathException { long ms = System.currentTimeMillis(); int iters = mcm.addSamples(500000); ms = System.currentTimeMillis() - ms; System.out.println(ms + " ms"); double rate = iters * 1000.0 / ms; System.out.format("%f iters/s %n", rate); double mean = summary.stats.getMean(); double stddev = summary.stats.getStandardDeviation(); System.out.println(iters); System.out.println(mean); System.out.println(stddev); assertEquals(expectedMean, mean, 0.01); // assertEquals(expectedStdDev, stddev, 0.05); }
public void testMeanAndVarianceParallel() throws MathException { LogArrivedPointValuation apv = new LogArrivedPointValuation(); mcm = new ParallelMonteCarloModel<Double>( new FastRandomFactory(), process, 1.0, 100, apv, summary, true, false); long ms = System.currentTimeMillis(); int iters = mcm.addSamples(500000); ms = System.currentTimeMillis() - ms; System.out.println(ms + " ms"); double rate = iters * 1000.0 / ms; System.out.format("%f iters/s %n", rate); double mean = summary.stats.getMean(); double stddev = summary.stats.getStandardDeviation(); System.out.println(iters); System.out.println(mean); System.out.println(stddev); assertEquals(expectedMean, mean, 0.01); assertEquals(expectedStdDev, stddev, 0.02); }