Is there a way to force Apache commons math to fit a linear curve of the form (y = mx + 0
) through the origin (0,0).
So far I've used both PolynomialCurveFitter and SimpleCurveFitter, but none of them is returning a result that passes through the origin.
E.g:
final WeightedObservedPoints wopts = new WeightedObservedPoints();
//Add observed points to wopts:
...
final PolynomialCurveFitter curveFitter = PolynomialCurveFitter.create(1);
double[] coeff = {0.0, 042}; //y = 0.042x + 0
curveFitter.withStartPoint(coeff);
final double[] bestPrediction = curveFitter.fit(wopts.toList());
but bestPrediction[0] is not 0.0 Any hint will be highly appreciated.