def fitLineLSQ(pts):
 n = len(pts)
 a = np.ones((n, 2))
 for i in range(n):
  a[(i, 0)] = pts[(i, 0)]
 line = lstsq(a, pts[:, 1])[0]
 return line

def fitLineLSQ ( pts ) : n = len ( pts ) a = np . ones ( ( n , 2 ) ) for i in range ( n ) : a [ ( i , 0 ) ] = pts [ ( i , 0 ) ] line = lstsq ( a , pts [ : , 1 ] ) [ 0 ] return line
returns a line fit with least squares .