/** * Gets the robust loess parameter estimates. * * @param y the dependent variable * @return the robust loess parameter estimates */ public static double[] getRobustLoessParameterEstimates(final double... y) { final double[] x = createIndependentArray(y.length); final SimpleRegression tricubeRegression = createWeightedLinearRegression(x, y, getTricubeWeights(y.length)); final double[] residuals = new double[y.length]; for (int i = 0; i < y.length; i++) { residuals[i] = y[i] - tricubeRegression.predict(x[i]); } final SimpleRegression tricubeBySqrRegression = createWeightedLinearRegression(x, y, getTricubeBisquareWeights(residuals)); final double[] estimates = tricubeBySqrRegression.regress().getParameterEstimates(); if (Double.isNaN(estimates[0]) || Double.isNaN(estimates[1])) { return tricubeRegression.regress().getParameterEstimates(); } return estimates; }