def regress(x, y=None):
if y is None:<EOL><INDENT>y = x<EOL>x = range(len(x))<EOL><DEDENT>if not isinstance(x[<NUM_LIT:0>], (float, int, np.float64, np.float32)):<EOL><INDENT>x = [row[<NUM_LIT:0>] for row in x]<EOL><DEDENT>A = np.vstack([np.array(x), np.ones(len(x))]).T<EOL>fit = np.linalg.lstsq(A, y, rcond=None)<EOL>poly = fit[<NUM_LIT:0>][<NUM_LIT:0>], fit[<NUM_LIT:0>][-<NUM_LIT:1>]<EOL>poly = regressionplot(x, y, poly)<EOL>return poly<EOL>
Fit a line to the x, y data supplied and plot it along with teh raw samples

>>> # Gainseville, FL census data shows 14 more new homes are built each year, starting with 517 completed in 1991
>>> poly = regress([483, 576, 529, 551, 529, 551, 663, 639, 704, 675, 601, 621, 630, 778, 831, 610])