Home > Back-end >  Curve fitting inverse function in python
Curve fitting inverse function in python

Time:03-14

I am trying to find a function which maps 20k data points.

enter image description here Image above is a plot of these 20k data points.

I tried to use an implementation of lagrange interpolate with Scipy package, I selected only 8 points to test but I don't understand the results (for exemple with f(343) it outputs -8244613 instead of a value close to 500).

I used these 8 points to find a good implementation: Data(12500, 0), Data(10000, 3), Data(7500, 11), Data(5000, 31), Data(2500, 88), Data(1000, 211), Data(400, 410), Data(20, 1756),

CodePudding user response:

lagrange fits n points to an n-th order polynomial. You can be sure that the points are on the curve described by the polynomial, but other than that the curve can go anywhere. This is what you observe as f(343)being far off 500 At first glance, your curve look more like a 1/x with some parameters for flavor.

Given the number of datapoints (and the unexciting nature of your dataset and no context given), I'd suggest linear interpolation between two adjacent points and expolation using the first and last pair.

  • Related