final WeightedObservedPoints obs = new WeightedObservedPoints();
for(int i = 0; i < pointList.size() - 1; i++) {
obs.add(i, getDistance(pointList.get(i), pointList.get(i + 1)));
obs.add(0,0);
obs.add(1,1);
obs.add(2,2);
obs.add(3,3);
}
// Instantiate a third-degree polynomial fitter.
final PolynomialCurveFitter fitter = PolynomialCurveFitter.create(3);
// Retrieve fitted parameters (coefficients of the polynomial function).
final double[] coeff = fitter.fit(obs.toList());
System.out.println(Arrays.toString(coeff));
我使用Apache Commons Math3来拟合多项式并得到以下错误。有什么想法吗?
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.commons.math3.util.Pair.getFirst()Ljava/lang/Object;
at org.apache.commons.math3.fitting.leastsquares.LeastSquaresFactory$LocalLeastSquaresProblem.evaluate(LeastSquaresFactory.java:431)
at org.apache.commons.math3.fitting.leastsquares.LeastSquaresAdapter.evaluate(LeastSquaresAdapter.java:60)
at org.apache.commons.math3.fitting.leastsquares.LeastSquaresFactory$1.evaluate(LeastSquaresFactory.java:197)
at org.apache.commons.math3.fitting.leastsquares.LevenbergMarquardtOptimizer.optimize(LevenbergMarquardtOptimizer.java:328)
at org.apache.commons.math3.fitting.AbstractCurveFitter.fit(AbstractCurveFitter.java:63)