[Python] Plots data points and the fitting polynomial using →→→→→进入此内容的聊天室

来自 , 2020-07-09, 写在 Python, 查看 157 次.
URL http://www.code666.cn/view/39d6530e
  1. ''' plotPoly(xData,yData,coeff)
  2.    Plots data points and the fitting
  3.    polynomial defined by its coefficient
  4.    array {coeff} = {a0, a1. ...}
  5. '''    
  6. from numpy import zeros,arange
  7. from xyPlot import *
  8.  
  9. def plotPoly(xData,yData,coeff):
  10.     m = len(coeff)
  11.     x1 = min(xData)
  12.     x2 = max(xData)
  13.     dx = (x2 - x1)/20.0  
  14.     x = arange(x1,x2 + dx/10.0,dx)
  15.     y = zeros((len(x)))*1.0
  16.     for i in range(m):
  17.         y = y + coeff[i]*x**i
  18.     xyPlot(xData,yData,'no',x,y,'ln')
  19. #//python/7407

回复 "Plots data points and the fitting polynomial using"

这儿你可以回复上面这条便签

captcha