SciPy-1
SciPy 1
Least-square fitting
For database (x[i], y[i]), we know there is functional relation called y=f(x), we know the f(x) as the f(x) = f(x, p), p is the set of undetermined coefficient. We need to know the p to make S the least :
$$
S(p) = \sum_{i=1}^{m}[y_i - f(x_i, p)]^2
$$
We use the bank optimize in scipy to realize the function of leastsq.
Here is the example. We are trying to fit a sine wave function.
1 |
|
Here is the result.
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!