Python:为数据列表找到最合适的函数 [英] Python: Find a best fit function for a list of data
问题描述
我知道通过random
模块内置的许多python内置概率函数.
I am aware of many probabilistic functions builted-in python, with the random
module.
我想知道,给定一个浮点数列表,是否有可能找到最适合该列表的分布方程?
I'd like to know if, given a list of floats, would be possible to find the distribution equation that best fits the list?
我不知道numpy是否这样做,但是可以将该功能与Excel的趋势"功能进行比较(不相等,但类似).
I don't know if numpy does it, but this function could be compared (not equal, but similar) with the Excel's "Trend" function.
我该怎么做?
推荐答案
numpy.polyfit(x, y, deg, rcond=None, full=False)
最小二乘多项式拟合.
Least squares polynomial fit.
拟合多项式p(x)= p [0] * x ** deg + ... + p°度deg (x,y).返回系数p的矢量,该矢量使平方误差最小.
Fit a polynomial p(x) = p[0] * x**deg + ... + p[deg] of degree deg to points (x, y). Returns a vector of coefficients p that minimises the squared error.
这篇关于Python:为数据列表找到最合适的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!