old_contents: from math import sqrt
  def linear_regression(X, Y):
      """
      http://www.answermysearches.com/how-to-do-a-simple-linear-regression-in-python/124/
      Summary
          Linear regression of y = ax + b
      Usage
          real, real, real = linreg(list, list)
          a, b, r2 = linreg(list, list)
      Returns coefficients to the regression line "y=ax+b" from x[] and y[], and R^2 Value
      """
      if len(X) != len(Y):  
          raise ValueError, 'unequal length'
      N = len(X)
      Sx = Sy = Sxx = Syy = Sxy = 0.0
      for x, y in map(None, X, Y):
          Sx = Sx + x
          Sy = Sy + y
          Sxx = Sxx + x*x
          Syy = Syy + y*y
          Sxy = Sxy + x*y
      det = Sxx * N - Sx * Sx
      a, b = (Sxy * N - Sy * Sx)/det, (Sxx * Sy - Sx * Sxy)/det
      meanerror = residual = 0.0
      for x, y in map(None, X, Y):
          meanerror = meanerror + (y - Sy/N)**2
          residual = residual + (y - a * x - b)**2
      RR = 1 - residual/meanerror
      ss = residual / (N-2)
      Var_a, Var_b = ss * N / det, ss * Sxx / det
      return a, b, RR
  
new_contents: from math import sqrt
  def linear_regression(X, Y):
      """
      http://www.answermysearches.com/how-to-do-a-simple-linear-regression-in-python/124/
      Summary
          Linear regression of y = ax + b
      Usage
          real, real, real = linreg(list, list)
          a, b, r2 = linreg(list, list)
      Returns coefficients to the regression line "y=ax+b" from x[] and y[], and R^2 Value
      """
      if len(X) != len(Y):  
          raise ValueError('unequal length')
      N = len(X)
      Sx = Sy = Sxx = Syy = Sxy = 0.0
      for x, y in map(None, X, Y):
          Sx = Sx + x
          Sy = Sy + y
          Sxx = Sxx + x*x
          Syy = Syy + y*y
          Sxy = Sxy + x*y
      det = Sxx * N - Sx * Sx
      a, b = (Sxy * N - Sy * Sx)/det, (Sxx * Sy - Sx * Sxy)/det
      meanerror = residual = 0.0
      for x, y in map(None, X, Y):
          meanerror = meanerror + (y - Sy/N)**2
          residual = residual + (y - a * x - b)**2
      RR = 1 - residual/meanerror
      ss = residual / (N-2)
      Var_a, Var_b = ss * N / det, ss * Sxx / det
      return a, b, RR
  
subject: Fix pep8 W602