Python: Find a best fit function for a list of data

故事扮演 提交于 2019-12-10 14:02:59

问题


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?

I don't know if numpy does it, but this function could be compared (not equal, but similar) with the Excel's "Trend" function.

How would I do that?


回答1:


Look at numpy.polyfit

numpy.polyfit(x, y, deg, rcond=None, full=False)¶
Least squares polynomial fit.

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.


来源:https://stackoverflow.com/questions/5762446/python-find-a-best-fit-function-for-a-list-of-data

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!