我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用scipy.poly1d()。
def _plot_correlation_func(x, y): r, p = pearsonr(x, y) title = "Cor($X_1$, $X_2$) = %.3f" % r pylab.scatter(x, y) pylab.title(title) pylab.xlabel("$X_1$") pylab.ylabel("$X_2$") f1 = scipy.poly1d(scipy.polyfit(x, y, 1)) pylab.plot(x, f1(x), "r--", linewidth=2) # pylab.xticks([w*7*24 for w in [0,1,2,3,4]], ['week %i'%(w+1) for w in # [0,1,2,3,4]])
def multiplyPoly(): #cubic1 has coefficients 3, 4, 5 and 5 cubic1 = sp.poly1d([3, 4, 5, 5]) #cubic2 has coefficients 4, 1, -3 and 3 cubic2 = sp.poly1d([4, 1, -3, 3]) print cubic1 print cubic2 print '-' * 36 #print results of polynomial multiplication print cubic1 * cubic2