FastICA (Fast Independent Component Analysis) implementation. This class provides a VB.NET port of the FastICA C reference implementation for recovering independent components from component mixtures. For the underlying theory, refer to the paper "ICA: Algorithms and Applications".
FastICA
01 Syntax
02 Methods
| Name | Overloads | Summary |
|---|---|---|
| PreprocessingCentering | 1 | Performs the centering operation on the observation matrix Xobs by subtracting the per-row mean from each observation. |
| PreprocessingWhitening | 1 | Performs the whitening operation on the centered matrix X. |
| SolveFastICA | 1 | Performs the FastICA algorithm to estimate the inverse of the mixing matrix. |
| ExportingData | 1 | Exports the estimated source data obtained from the FastICA algorithm. |
| Initialize | 1 | Generates the random mixing matrix Amix, used to build the observation matrix Xobs containing the M observed mixtures of the N sources. |
| SetUpSources | 1 | Generates the source matrix S, containing the source signals used to build the observation matrix data. |
| XobsGen | 1 | Generates the observation matrix , consisting of M observed mixture samples of size N, by multiplying the mixing matrix Amix with the source matrix S. |
| FreeMemory | 1 | Frees the memory allocated for the execution of the algorithm by erasing all working matrices and vectors. |
| MatMult | 1 | Performs the matrix multiplication of two matrices A and B (A * B). |
| VecMatMult | 1 | Performs the multiplication of a row vector V by a matrix B (V * B). |
| MatVecMult | 1 | Performs the multiplication of a matrix B by a column vector V (B * V). |
| MatTranspose | 1 | Computes the transpose of matrix A. |
| VectorNormalization | 1 | Normalizes a vector wp to unit length (L2 norm == 1). |
| EigenDecomposition | 1 | Computes the eigenvalues and eigenvectors of a real, symmetric N x N matrix. |
| setupVars | 1 | Sets up the various parameters and allocates the working matrices/vectors used by the algorithm. |
| Main | 1 | Main entry point of the FastICA algorithm. |
| ParameterInput | 1 | Sets the user-configurable parameters of the algorithm. |
| funcSource1 | 1 | First source signal: a sine wave with angular frequency 1.1. |
| funcSource2 | 1 | Second source signal: a cosine wave with angular frequency 0.25. |
| funcSource3 | 1 | Third source signal: a sine wave with angular frequency 0.1. |
| funcSource4 | 1 | Fourth source signal: a cosine wave with angular frequency 0.7. |
| funcSource5 | 1 | Fifth source signal: a saw-tooth (zig-zag) wave defined by the slope K and period periodSource5. |
| funcSource6 | 1 | Sixth source signal: an alternating step function (+1 / -1) with period periodSource6. |
03 Fields
| Name | Overloads | Summary |
|---|---|---|
| iterations | 2 | Number of FastICA fixed-point iterations used in FastICA.SolveFastICA()). |
| N | 2 | Number of sources (rows of the observation matrix). |
| C | 2 | Number of observations (sample size); should equal FastICA.N. |
| M | 2 | Number of observation samples (columns of the observation matrix). |
| p | 2 | Helper loop index used during source setup. |
| finalTime | 2 | Final simulation time (seconds). |
| initialTime | 2 | Initial simulation time (seconds). |
| K | 2 | Slope of the zig-zag source (funcSource5). |
| na | 2 | Number of zig-zag source periods (amount of peaks). |
| ns | 2 | Number of alternating step-function periods (funcSource6). |
| Amix | 2 | The mixing matrix A (N x N) used to generate the observation matrix. |
| W | 2 | The estimated inverse of the mixing matrix W (N x N). |
| WT | 2 | Transpose of the estimated inverse mixing matrix W (N x N). |
| timeVector | 2 | Time vector used while generating the source signals. |
| S | 2 | The generated source matrix S (M x N). |
| Sest | 2 | The estimated source matrix Sest (M x N). |
| Xobs | 2 | The generated observation matrix Xobs (M x N). |
| X | 2 | The centered observation matrix X (M x N). |
| Z | 2 | The whitened observation matrix Z (M x N). |
| periodSource5 | 2 | Period of the zig-zag source (funcSource5). |
| periodSource6 | 2 | Period of the step-function source (funcSource6). |
| avgsource5 | 2 | Mean value of the fifth source signal. |
| avgsource6 | 2 | Mean value of the sixth source signal. |
| time_spent | 2 | Elapsed computation time of the algorithm. |
| begin | 2 | Timestamp recorded at the start of FastICA.Main(). |
| end | 2 | Timestamp recorded at the end of FastICA.Main(). |
| RAND_MAX | 1 | The maximum value returned by the pseudo-random number generator, used to normalize generated values into the [0, 1) range. |
04 Members
Double()(), Int32, Int32)Performs the centering operation on the observation matrix Xobs by subtracting the per-row mean from each observation.
| Name | Type | Description |
|---|---|---|
Xobs | Double()() | The original observation matrix (N x M). |
N | Int32 | Number of sources (rows). |
M | Int32 | Number of observation samples (columns). |
The centered matrix X (M x N).
Double()(), Int32, Int32)Performs the whitening operation on the centered matrix X. Whitening transforms the data so that its components are uncorrelated and have unit variance, which is a required precondition for the FastICA algorithm.
The eigen decomposition uses 100 iterations by default. This value can be changed by adjusting iterationsED inside this routine.
| Name | Type | Description |
|---|---|---|
X | Double()() | The centered observation matrix (M x N). |
N | Int32 | Number of sources. |
M | Int32 | Number of observation samples. |
The whitened matrix Z (M x N).
Double()(), Int32, Int32, Int32)Performs the FastICA algorithm to estimate the inverse of the mixing matrix.
Uses the tanh non-linearity and Gram-Schmidt decorrelation between estimated components. For the underlying theory, refer to "ICA: Algorithms and Applications".
| Name | Type | Description |
|---|---|---|
Z | Double()() | The whitened observation matrix (M x N). |
N | Int32 | Number of sources. |
M | Int32 | Number of observation samples. |
iterations | Int32 | Maximum number of fixed-point iterations per component (default 1000). |
The estimated inverse of the mixing matrix W (N x N).
Exports the estimated source data obtained from the FastICA algorithm.
In the original C implementation this routine wrote the estimated sources Sest and the timeVector to the text file "SourcesEstimation.txt" for visualization in Matlab (ReadingData.m). The VB port is left empty to keep the call chain intact without performing file I/O.
Generates the random mixing matrix Amix, used to build the observation matrix Xobs containing the M observed mixtures of the N sources.
Generates the source matrix S, containing the source signals used to build the observation matrix data.
Sources 5 and 6 are subsequently mean-centered (their average is subtracted) to satisfy the zero-mean requirement of ICA.
Double()(), Double()(), Int32, Int32)Generates the observation matrix , consisting of M observed mixture samples of size N, by multiplying the mixing matrix Amix with the source matrix S.
| Name | Type | Description |
|---|---|---|
Amix | Double()() | The mixing matrix (N x N). |
S | Double()() | The source matrix (M x N). |
N | Int32 | Number of sources. |
M | Int32 | Number of observation samples. |
The observation matrix Xobs (M x N).
Frees the memory allocated for the execution of the algorithm by erasing all working matrices and vectors.
Double()(), Int32, Int32, Double()(), Int32, Int32)Performs the matrix multiplication of two matrices A and B (A * B).
| Name | Type | Description |
|---|---|---|
A | Double()() | The left matrix (rows1 x columns1). |
rows1 | Int32 | Number of rows of A. |
columns1 | Int32 | Number of columns of A (must equal rows of B). |
B | Double()() | The right matrix (rows2 x columns2). |
rows2 | Int32 | Number of rows of B. |
columns2 | Int32 | Number of columns of B. |
The product matrix Sp = A * B (rows1 x columns2).
Double(), Int32, Double()(), Int32)Performs the multiplication of a row vector V by a matrix B (V * B).
| Name | Type | Description |
|---|---|---|
V | Double() | The row vector (passed ByRef). |
SizeVec | Int32 | Length of the vector V (must equal rows of B). |
B | Double()() | The matrix B (SizeVec x columns). |
columns | Int32 | Number of columns of B. |
The result vector Sp = V * B (length columns).
Double()(), Int32, Int32, Double())Performs the multiplication of a matrix B by a column vector V (B * V).
| Name | Type | Description |
|---|---|---|
B | Double()() | The matrix B (rows x columns). |
rows | Int32 | Number of rows of B. |
columns | Int32 | Number of columns of B (must equal length of V). |
V | Double() | The column vector (passed ByRef). |
The result vector Sp = B * V (length rows).
Double()(), Int32, Int32)Computes the transpose of matrix A. The result Sp = A' (Matlab notation) is returned.
| Name | Type | Description |
|---|---|---|
A | Double()() | The input matrix (rows x columns). |
rows | Int32 | Number of rows of A. |
columns | Int32 | Number of columns of A. |
The transposed matrix Sp (columns x rows).
Double(), Int32)Normalizes a vector wp to unit length (L2 norm == 1).
| Name | Type | Description |
|---|---|---|
wp | Double() | The vector to normalize (passed ByRef, modified in place). |
sizeVec | Int32 | Length of the vector. |
Double()(), Int32, Double()(), Double(), Int32)Computes the eigenvalues and eigenvectors of a real, symmetric N x N matrix.
Uses a Jacobi-like iterative rotation with Gram-Schmidt orthogonalization of the eigenvectors during each iteration.
| Name | Type | Description |
|---|---|---|
ExxT | Double()() | The input symmetric matrix (N x N). |
N | Int32 | Matrix dimension. |
EigVectors | Double()() | Output eigenvectors matrix (N x N), modified in place. |
EigValues | Double() | Output eigenvalues vector (length N), returned ByRef. |
iterations | Int32 | Number of decomposition iterations. |
Sets up the various parameters and allocates the working matrices/vectors used by the algorithm.
Main entry point of the FastICA algorithm. Orchestrates parameter input, data generation, preprocessing, the FastICA core, estimation output and cleanup, and prints the elapsed time.
0 on completion.
Sets the user-configurable parameters of the algorithm. This is the only section that the user is expected to modify.
Six sources are available by default. To use more sources they must be added in FastICA.SetUpSources() and FastICA.funcSource1() ... FastICA.funcSource6(); to use fewer, remove the excess from FastICA.SetUpSources().
Double)First source signal: a sine wave with angular frequency 1.1.
| Name | Type | Description |
|---|---|---|
x | Double | The time value. |
The value of the source signal.
Double)Second source signal: a cosine wave with angular frequency 0.25.
| Name | Type | Description |
|---|---|---|
x | Double | The time value. |
The value of the source signal.
Double)Third source signal: a sine wave with angular frequency 0.1.
| Name | Type | Description |
|---|---|---|
x | Double | The time value. |
The value of the source signal.
Double)Fourth source signal: a cosine wave with angular frequency 0.7.
| Name | Type | Description |
|---|---|---|
x | Double | The time value. |
The value of the source signal.
Double)Fifth source signal: a saw-tooth (zig-zag) wave defined by the slope K and period periodSource5.
| Name | Type | Description |
|---|---|---|
x | Double | The time value. |
The value of the source signal.
Double)Sixth source signal: an alternating step function (+1 / -1) with period periodSource6.
| Name | Type | Description |
|---|---|---|
x | Double | The time value. |
The value of the source signal (+1 or -1).
Number of FastICA fixed-point iterations used in FastICA.SolveFastICA().
Number of sources (rows of the observation matrix).
Number of observations (sample size); should equal FastICA.N.
Number of observation samples (columns of the observation matrix).
Helper loop index used during source setup.
Final simulation time (seconds).
Initial simulation time (seconds).
Slope of the zig-zag source (funcSource5).
Number of zig-zag source periods (amount of peaks).
Number of alternating step-function periods (funcSource6).
The mixing matrix A (N x N) used to generate the observation matrix.
The estimated inverse of the mixing matrix W (N x N).
Transpose of the estimated inverse mixing matrix W (N x N).
Time vector used while generating the source signals.
The generated source matrix S (M x N).
The estimated source matrix Sest (M x N).
The generated observation matrix Xobs (M x N).
The centered observation matrix X (M x N).
The whitened observation matrix Z (M x N).
Period of the zig-zag source (funcSource5).
Period of the step-function source (funcSource6).
Mean value of the fifth source signal.
Mean value of the sixth source signal.
Elapsed computation time of the algorithm.
Timestamp recorded at the start of FastICA.Main().
Timestamp recorded at the end of FastICA.Main().
The maximum value returned by the pseudo-random number generator, used to normalize generated values into the [0, 1) range. Mirrors the C RAND_MAX constant.