Class SvdAndPca
contains methods and test example to do Singular Value decomposition and Principal Components Analysis
IMPORTANT NOTE: The underlying storage of the Matrix class is a one dimensional array in column-major order (column by column). NOT Row by row!!.
Inherited Members
Namespace: TowseyLibrary
Assembly: TowseyLibrary.dll
Syntax
public static class SvdAndPca
Methods
| Improve this Doc View SourceEigenVectors(Double[,])
returns the eigen values and eigen vectors of a matrix IMPORTANT: THIS METHOD NEEDS DEBUGGING. IT RETURNS THE NEGATIVE VALUES OF THE EIGEN VECTORS ON A TOY EXMAPLE double[,] matrix = { { 3.0, -1.0 }, { -1.0, 3.0 } }; eigen values are correct ie, 2.0, 4.0; but in the wrong order.
Declaration
public static Tuple<double[], double[, ]> EigenVectors(double[, ] matrix)
Parameters
Type | Name | Description |
---|---|---|
Double[,] | matrix |
Returns
Type | Description |
---|---|
Tuple<Double[], Double[,]> |
ExampleOfSVD_1()
Declaration
public static void ExampleOfSVD_1()
ExampleOfSVD_2()
Declaration
public static void ExampleOfSVD_2()
ExampleOfSVD_3()
These examples are used to do Wavelet Packet Decomposition and then do SVD on the returned WPD trees.
Declaration
public static void ExampleOfSVD_3()
SingularValueDecompositionOutput(Double[,])
Declaration
public static Tuple<Vector<double>, Matrix<double>> SingularValueDecompositionOutput(double[, ] matrix)
Parameters
Type | Name | Description |
---|---|---|
Double[,] | matrix |
Returns
Type | Description |
---|---|
Tuple<MathNet.Numerics.LinearAlgebra.Vector<Double>, MathNet.Numerics.LinearAlgebra.Matrix<Double>> |
SingularValueDecompositionVector(Double[,])
The singular value decomposition of an M by N rectangular matrix A has the form A(mxn) = U(mxm) * S(mxn) * V'(nxn) where U is an orthogonal matrix, whose columns are the left singular vectors; S is a diagonal matrix, whose min(m,n) diagonal entries are the singular values; V is an orthogonal matrix, whose columns are the right singular vectors; Note 1: the transpose of V is used in the decomposition, and that the diagonal matrix S is typically stored as a vector. Note 2: the values on the diagonal of S are the square-root of the eigenvalues.
THESE TWO METHODS HAVE BEEN TESTED ON TOY EXAMPLES AND returned correct values.
Declaration
public static double[] SingularValueDecompositionVector(double[, ] matrix)
Parameters
Type | Name | Description |
---|---|---|
Double[,] | matrix |
Returns
Type | Description |
---|---|
Double[] |
TestEigenValues()
Declaration
public static void TestEigenValues()