def LeastSquares(xs, ys):
 (meanx, varx) = MeanVar(xs)
 meany = Mean(ys)
 slope = (Cov(xs, ys, meanx, meany) / varx)
 inter = (meany - (slope * meanx))
 return (inter, slope)

def LeastSquares ( xs , ys ) : ( meanx , varx ) = MeanVar ( xs ) meany = Mean ( ys ) slope = ( Cov ( xs , ys , meanx , meany ) / varx ) inter = ( meany - ( slope * meanx ) ) return ( inter , slope )
computes a linear least squares fit for ys as a function of xs .