问题描述
我必须使用Excel的LINEST函数来计算线性回归中的误差.我希望使用Numpy的polyfit函数重现结果.我希望重现以下LINEST用法:
I have to use Excel's LINEST function to compute error in my linear regression. I was hoping to reproduce the results using Numpy's polyfit function. I was hoping to reproduce the following LINEST usage:
LINEST(y's,x's ,, TRUE)
与polyfit.我不确定如何使两个函数产生相同的值,因为我尝试过的任何方法都不会产生相似的结果.
with polyfit. I'm not sure how I can get the two functions to produce the same values because nothing I've tried gives similar results.
我尝试了以下操作:
numpy.polyfit(x,y,3)
和其他各种值位于第三位置.
and various other values in the third position.
推荐答案
这个问题实际上是我对NumPy的polyfit函数和LINEST的误解造成的.执行以下操作:
This question is actually a result of my misunderstanding of NumPy's polyfit function and LINEST. Doing the following:
numpy.polyfit(x,y,1)
为我提供了正确的结果,因为它使用样本 x
和 y
值(例如LINEST)执行了线性回归.
gave me the correct result because it performs a linear regression using the sample x
and y
values like LINEST.
这篇关于用NumPy重现Excel的LINEST函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!