def fit_linear(xdata, ydata):
x = _n.array(xdata)<EOL>y = _n.array(ydata)<EOL>ax  = _n.average(x)<EOL>ay  = _n.average(y)<EOL>axx = _n.average(x*x)<EOL>ayx = _n.average(y*x)<EOL>slope     = (ayx - ay*ax) / (axx - ax*ax)<EOL>intercept = ay - slope*ax<EOL>return slope, intercept<EOL>
Returns slope and intercept of line of best fit:

    y = a*x + b

through the supplied data.

Parameters
----------
xdata, ydata:
    Arrays of x data and y data (having matching lengths).