赞
踩
I am looking for a way to fit
parametric equations to a set of data points, using Python.
As a simple example, given is the following set of data points:
import numpy as np
x_data = np.array([1, 2, 3, 4, 5])
y_data = np.array([2, 0, 3, 7, 13])
Using t as the parameter, I want to fit the following parametric equation to the data points,
t = np.arange(0, 5, 0.1)
x = a1*t + b1
y = a2*t**2 + b2*t + c2
that is, have Python find the values for the coefficients a1, b1, a2, b2, c2 that fits (x,y) best to the data points (x_data, y_data).
Note that the y(t) and x(t) functions above only serve as examples of parametric equations. The actual functions I want to fit my data to are much more complex, and in those functions, it is not trivial to express y as a function of x.
Help wi
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。