def linearRegression(xyList):
    """Return the coefficients a b so that yList ~= a * xList + b."""
    avgX, avgY, avgX2, avgXY = 0, 0, 0, 0
    for x, y in xyList:
        avgX += x
        avgY += y
        avgX2 += x**2
        avgXY += x*y
    a = float(avgXY - avgX * avgY) / float(avgX2 - avgX**2)
    b = avgY - a * avgX

    return (a, int(b))