Suppose I have a hypotetical function I'd like to approximate:
def f(x):
return a * x ** 2 + b * x + c
Where a
, b
and c
are the values I don't know.
And I have certain points where the function output is known, i.e.
x = [-1, 2, 5, 100]
y = [123, 456, 789, 1255]
(actually there are way more values)
I'd like to get a
, b
and c
while minimizing the squared error (and additionally get that squared error).
What is the way to do that in Python?
There should be existing solutions in scipy
, numpy
or anywhere like that.