Skip to content

Instantly share code, notes, and snippets.

@lettergram
Created March 19, 2015 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lettergram/a165360d5dfecb45a3e6 to your computer and use it in GitHub Desktop.
Save lettergram/a165360d5dfecb45a3e6 to your computer and use it in GitHub Desktop.
def svd_LeastSquares(A, b):
U, s, V = np.linalg.svd(A)
r = [0.0, 0.0]
r += (1/s[0]) * (U[:,0].T*b) * (V[:,0].T)
r += (1/s[1]) * (U[:,1].T*b) * (V[:,1].T)
return r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment