/** * Returns the degree of the polynomial. * * @return the polynomial degree * @throws NullPointerException * if {@link #fitPolynomial(int)} has not been called */ public int getPolynomialDegree() { validateFit(); return pFunction.degree(); }
/** * Returns RSquared of the polynomial fit. Implementation from <a href= * "https://en.wikipedia.org/wiki/Coefficient_of_determination">wikipedia</a>. * \( R^2 = 1 - (SSres/SStot) \) with \( SSres = SUM(i) (yi - fi)^2 \) \( * SStot = SUM(i) (yi - yavg)^2 \) * * @param adjusted * if {@code true} returns adjusted RSquared, i.e., adjusted for * the number of terms of the polynomial model * @return RSquared, a measure for the goodness of fit * @throws NullPointerException * if {@link #fitPolynomial(int)} has not been called */ public double getRSquaredOfFit(final boolean adjusted) { if (adjusted) { final int p = pFunction.degree() - 1; return getAdjustedRSquaredOfFit(p); } return getRSquaredOfFit(); }