当前位置:   article > 正文

python拟合曲线并得出方程式,如何在Python中将参数方程式拟合到数据点

numpy 拟合后显示方程

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/683741
推荐阅读
相关标签
  

闽ICP备14008679号