* @since 2.1
*/
public final double[] smooth(final double[] xval, final double[] yval, final double[] weights)
throws MathException {
if (xval.length != yval.length) {
throw new MathException(LocalizedFormats.MISMATCHED_LOESS_ABSCISSA_ORDINATE_ARRAYS,
xval.length, yval.length);
}
final int n = xval.length;
if (n == 0) {
throw new MathException(LocalizedFormats.LOESS_EXPECTS_AT_LEAST_ONE_POINT);
}
checkAllFiniteReal(xval, LocalizedFormats.NON_REAL_FINITE_ABSCISSA);
checkAllFiniteReal(yval, LocalizedFormats.NON_REAL_FINITE_ORDINATE);
checkAllFiniteReal(weights, LocalizedFormats.NON_REAL_FINITE_WEIGHT);
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(LocalizedFormats.TOO_SMALL_BANDWIDTH,
n, 2.0 / n, bandwidth);
}
final double[] res = new double[n];