Fitting a broken line

(BenjaminS) #1


i try to fit a curve based on 3 lines connected at their ends (broken line with 2 inner knots).
The first and the last point is fix, the position of the two inner knots should be optimized.

I have a c# function (method) describing my target function with 4 parameters to optimize bx,by,cx,cy.
Is it possible to use fit to find the best values for the 4 parameters?

public double FunctionBrokenLine2Knots(double x, double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy)
            double result;
            double[] points = new double[4] {ax,bx,cx,dx };
            double[] values = new double[4] {ay,by,cy,dy };
            var r2 = MathNet.Numerics.Interpolate.Linear(points, values);
            result = r2.Interpolate(x);
            return result;