singular value decomposition
http://web.stanford.edu/class/cs246/slides/dim-red.pdf
http://web.mit.edu/be.400/www/SVD/Singular_Value_Decomposition.htm
http://mathworld.wolfram.com/SingularValueDecomposition.html
https://www.cs.cmu.edu/~venkatg/teaching/CStheory-infoage/book-chapter-4.pdf
【close to a matrix of low rank 用低秩矩阵逼近 svd是得到低秩矩阵的计算方法之一】
First, in many applications, the data matrix A is close to a
matrix of low rank and it is useful to find a low rank matrix which is a good approximation
to the data matrix .
【从一维直线切入】
To gain insight into the SVD, treat the rows of an n × d matrix A as n points in a
d-dimensional space and consider the problem of finding the best k-dimensional subspace
with respect to the set of points. Here best means minimize the sum of the squares of the
perpendicular distances of the points to the subspace. We begin with a special case of
the problem where the subspace is 1-dimensional, a line through the origin. We will see
later that the best-fitting k-dimensional subspace can be found by k applications of the
best fitting line algorithm. Finding the best fitting line through the origin with respect
to a set of points {xi|1 ≤ i ≤ n} in the plane means minimizing the sum of the squared
distances of the points to the line. Here distance is measured perpendicular to the line.
The problem is called the best least squares fit.
Singular matrix
C:\Python36\python.exe "C:\Program Files (x86)\JetBrains\PyCharm 2017.1\helpers\pydev\pydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 63304 --file D:/pymine/clean/filter_mac/1.py pydev debugger: process 49536 is connecting Connected to pydev debugger (build 171.3780.115) Traceback (most recent call last): File "C:\Program Files (x86)\JetBrains\PyCharm 2017.1\helpers\pydev\pydevd.py", line 1578, in <module> globals = debugger.run(setup['file'], None, None, is_module) File "C:\Program Files (x86)\JetBrains\PyCharm 2017.1\helpers\pydev\pydevd.py", line 1015, in run pydev_imports.execfile(file, globals, locals) # execute the script File "C:\Program Files (x86)\JetBrains\PyCharm 2017.1\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "D:/pymine/clean/filter_mac/1.py", line 16, in <module> x = np.linalg.solve(a, b) File "C:\Python36\lib\site-packages\numpy\linalg\linalg.py", line 375, in solve r = gufunc(a, b, signature=signature, extobj=extobj) File "C:\Python36\lib\site-packages\numpy\linalg\linalg.py", line 90, in _raise_linalgerror_singular raise LinAlgError("Singular matrix") numpy.linalg.linalg.LinAlgError: Singular matrix
import numpy as np a, b = np.matrix('1 1;1 1'), np.matrix('1;1') c = a * b a, b = np.array([[3, 1], [1, 2]]), np.array([9, 8]) x = np.linalg.solve(a, b) a, b = np.array([[1, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, -1]]), np.array([8, 13, 8, 6]) x = np.linalg.solve(a, b) a, b = np.array([[1, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, -1]]), np.array([8, 13, 8, 6]) x = np.linalg.solve(a, b) a, b = np.array([[1, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, -1]]), np.array([8, 13, 8, 6]) x = np.linalg.solve(a, b)
import numpy as np a, b = np.matrix('1 1;1 1'), np.matrix('1;1') c = a * b a, b = np.array([[3, 1], [1, 2]]), np.array([9, 8]) x = np.linalg.solve(a, b) a, b = np.array([[1, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, -1]]), np.array([8, 13, 8, 6]) x = np.linalg.solve(a, b) a, b = np.array([[1, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, -1]]), np.array([8, 13, 8, 6]) x = np.linalg.solve(a, b) a, b = np.array([[1, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, -1]]), np.array([8, 13, 8, 6]) x = np.linalg.solve(a, b) a, b = np.array([[1, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]), np.array([8, 13, 8, 6]) x = np.linalg.solve(a, b) s = 9
C:\Python36\python.exe "C:\Program Files (x86)\JetBrains\PyCharm 2017.1\helpers\pydev\pydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 64411 --file D:/pymine/clean/filter_mac/1.py pydev debugger: process 27204 is connecting Connected to pydev debugger (build 171.3780.115) Traceback (most recent call last): File "C:\Program Files (x86)\JetBrains\PyCharm 2017.1\helpers\pydev\pydevd.py", line 1578, in <module> globals = debugger.run(setup['file'], None, None, is_module) File "C:\Program Files (x86)\JetBrains\PyCharm 2017.1\helpers\pydev\pydevd.py", line 1015, in run pydev_imports.execfile(file, globals, locals) # execute the script File "C:\Program Files (x86)\JetBrains\PyCharm 2017.1\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "D:/pymine/clean/filter_mac/1.py", line 16, in <module> x = np.linalg.solve(a, b) File "C:\Python36\lib\site-packages\numpy\linalg\linalg.py", line 375, in solve r = gufunc(a, b, signature=signature, extobj=extobj) File "C:\Python36\lib\site-packages\numpy\linalg\linalg.py", line 90, in _raise_linalgerror_singular raise LinAlgError("Singular matrix") numpy.linalg.linalg.LinAlgError: Singular matrix
http://mathworld.wolfram.com/SingularMatrix.html
A square matrix that does not have a matrix inverse. A matrix is singular iff its determinant is 0.
【当且仅当 -- 方阵且行列式为0】奇异矩阵首先是方阵,其次是行列式值为0;;;
http://mathworld.wolfram.com/Determinant.html