/** * Gets the tricube bisquare weigths. * * @param residuals the residuals array * @return the tricube bisquare weigths */ public static double[] getTricubeBisquareWeights(final double... residuals) { final double[] weights = getTricubeWeights(residuals.length); final double[] weights2 = new double[residuals.length]; final double s6 = median(abs(residuals)) * 6; for (int i = 2; i < residuals.length; i++) { final double k = Math.pow(1 - Math.pow(residuals[i] / s6, 2), 2); weights2[i] = k > 0 ? (1 / k) * weights[i] : Double.MAX_VALUE; } weights2[0] = weights2[1] = weights2[2]; return weights2; }
/** * Gets the tricube bisquare weigths. * * @param residuals the residuals array * @return the tricube bisquare weigths * @todo The word "weight" is misspelled in the method name. */ public static double[] getTricubeBisquareWeigts(final double[] residuals) { int n = residuals.length; double[] weights = getTricubeWeigts(n); double[] weights2 = new double[n]; double s6 = median(abs(residuals)) * 6; for (int i = 2; i < n; i++) { double k = Math.pow(1 - Math.pow(residuals[i] / s6, 2), 2); if (k > 0) { weights2[i] = (1 / k) * weights[i]; } else { weights2[i] = Double.MAX_VALUE; } } weights2[0] = weights2[1] = weights2[2]; return weights2; }