// Hyman 1989 paper the n=17 nonmonotonicity is not filtered anymore
// so the error agrees with the non MC method.
final double tabulatedMCErrors[] = { 1.7e-2, 2.0e-3, 4.0e-5, 1.8e-6 };
final double toleranceOnTabMCErr[] = { 0.1e-2, 0.1e-3, 0.1e-5, 0.1e-6 };
final SimpsonIntegral integral = new SimpsonIntegral(1e-12, 10000);
// still unexplained scale factor needed to obtain the numerical results from the paper
final double scaleFactor = 1.9;
for (int i=0; i<points.length; i++) {
final int n = points[i];
final Array x = xRange(-1.7, 1.9, n);
final Array y = gaussian(x);
double result;
// Not-a-knot
CubicInterpolation f = new CubicInterpolation(
x, y,
CubicInterpolation.DerivativeApprox.Spline, false,
CubicInterpolation.BoundaryCondition.NotAKnot, Constants.NULL_REAL,
CubicInterpolation.BoundaryCondition.NotAKnot, Constants.NULL_REAL);
f.update();
result = Math.sqrt(integral.op(makeErrorFunction(f), -1.7, 1.9));
result /= scaleFactor;
assertFalse("Not-a-knot spline interpolation "
+"\n sample points: "+n
+"\n norm of difference: "+result
+"\n it should be: "+tabulatedErrors[i],
abs(result-tabulatedErrors[i]) > toleranceOnTabErr[i]);
// MC not-a-knot
f = new CubicInterpolation(
x, y,
CubicInterpolation.DerivativeApprox.Spline, true,
CubicInterpolation.BoundaryCondition.NotAKnot, Constants.NULL_REAL,
CubicInterpolation.BoundaryCondition.NotAKnot, Constants.NULL_REAL);
f.update();
result = Math.sqrt(integral.op(makeErrorFunction(f), -1.7, 1.9));
result /= scaleFactor;
assertFalse ("MC Not-a-knot spline interpolation "
+ "\n sample points: "
+ "\n norm of difference: " + result
+ "\n it should be: " + tabulatedErrors[i],