Created
November 5, 2015 03:55
-
-
Save kyoro1/44a2b4602f6109f6723a to your computer and use it in GitHub Desktop.
Pythonで特異値分解してみる ref: http://qiita.com/kyoro1/items/4df11e933e737703d549
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A=U\Sigma \overline{V^T} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A=\left( | |
\begin{matrix} | |
1 & 2 \\ | |
3 & 4 | |
\end{matrix} | |
\right) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> np.dot(V, V.T) | |
array([[ 1., 0.], | |
[ 0., 1.]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> import numpy as np | |
> A = np.array([[1,2],[3,4]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> A | |
array([[1, 2], | |
[3, 4]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
U, s, V = np.linalg.svd(A, full_matrices=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> U | |
array([[-0.40455358, -0.9145143 ], | |
[-0.9145143 , 0.40455358]]) | |
> s | |
array([ 5.4649857 , 0.36596619]) | |
> V | |
array([[-0.57604844, -0.81741556], | |
[ 0.81741556, -0.57604844]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> np.diag(s) | |
array([[ 5.4649857 , 0. ], | |
[ 0. , 0.36596619]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A=U\Sigma \overline{V^T} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>np.dot(np.dot(U, np.diag(s)),V) | |
array([[ 1., 2.], | |
[ 3., 4.]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> np.dot(U, U.T) | |
array([[ 1.00000000e+00, 2.77555756e-16], | |
[ 2.77555756e-16, 1.00000000e+00]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment