* </ul>
*/
public final double[] smooth(final double[] xval, final double[] yval)
throws MathException {
if (xval.length != yval.length) {
throw new MathException(
"Loess expects the abscissa and ordinate arrays " +
"to be of the same size, " +
"but got {0} abscisssae and {1} ordinatae",
xval.length, yval.length);
}
final int n = xval.length;
if (n == 0) {
throw new MathException("Loess expects at least 1 point");
}
checkAllFiniteReal(xval, true);
checkAllFiniteReal(yval, false);
checkStrictlyIncreasing(xval);
if (n == 1) {
return new double[]{yval[0]};
}
if (n == 2) {
return new double[]{yval[0], yval[1]};
}
int bandwidthInPoints = (int) (bandwidth * n);
if (bandwidthInPoints < 2) {
throw new MathException(
"the bandwidth must be large enough to " +
"accomodate at least 2 points. There are {0} " +
" data points, and bandwidth must be at least {1} " +
" but it is only {2}",
n, 2.0 / n, bandwidth);