arange generates lists (well, numpy arrays); type help(np.arange) for details. You do not need to call it in existing lists.
>>> x = [1,2,3,4] >>> y = [3,5,7,9] >>> >>> m,b = np.polyfit(x, y, 1) >>> m 2.0000000000000009 >>> b 0.99999999999999833
I should add that I prefer to use poly1d here instead of writing "m * x + b" and higher order equivalents, so my version of your code will look something like this:
import numpy as np import matplotlib.pyplot as plt x = [1,2,3,4] y = [3,5,7,10]
DSM May 27 '11 at 5:47 a.m. 2011-05-27 05:47
source share