{
xValues[i] = minimumX + delta * (double) i;
yValues[i] = f.value( xValues[i] );
}
UnivariateFunction interpolation = new AkimaSplineInterpolator().interpolate( xValues, yValues );
for ( int i = 0; i < numberOfElements; i++ )
{
currentX = xValues[i];
expected = f.value( currentX );
actual = interpolation.value( currentX );
assertTrue( Precision.equals( expected, actual ) );
}
final RandomGenerator rng = new Well19937c( 1234567L ); // "tol" depends on the seed.
final UniformRealDistribution distX =
new UniformRealDistribution( rng, xValues[0], xValues[xValues.length - 1] );
double sumError = 0;
for ( int i = 0; i < numberOfSamples; i++ )
{
currentX = distX.sample();
expected = f.value( currentX );
actual = interpolation.value( currentX );
sumError += FastMath.abs( actual - expected );
assertEquals( expected, actual, maxTolerance );
}
assertEquals( 0.0, ( sumError / (double) numberOfSamples ), tolerance );