I am trying to fit a curve with a 2-nd degree polynomial regression using PolynomialCurveFitter in Java with Apache Maths. This is my code:
final WeightedObservedPoints obs = new WeightedObservedPoints();
obs.add(1, 3400);
obs.add(3, 6000);
obs.add(8, 9600);
obs.add(10, 30000);
// Instantiate a third-degree polynomial fitter.
final PolynomialCurveFitter fitter = PolynomialCurveFitter.create(2);
// Retrieve fitted parameters (coefficients of the polynomial function).
final double[] coeff = fitter.fit(obs.toList());
//System.out.println(coeff);
System.out.println("coef="+Arrays.toString(coeff));
And it's working fine, but I would like to intercept at (0,0), i.e. my constant term in the equation to be zero: y=ax+bx^2.
Thank you very much for your help, Fred