Implementation:Haifengl Smile ICA
| Knowledge Sources | |
|---|---|
| Domains | Signal Processing, Dimensionality Reduction, Machine Learning |
| Last Updated | 2026-02-08 22:00 GMT |
Overview
ICA is a record class implementing Independent Component Analysis using the FastICA algorithm to separate a multivariate signal into additive, statistically independent components.
Description
ICA implements the FastICA algorithm by Aapo Hyvarinen for Independent Component Analysis. The algorithm seeks an orthogonal rotation of prewhitened data through a fixed-point iteration scheme that maximizes a measure of non-Gaussianity of the rotated components. Non-Gaussianity serves as a proxy for statistical independence.
The class supports three built-in contrast (non-linear) functions:
- LogCosh - based on the log of the hyperbolic cosine function.
- Gaussian (Exp) - based on the exponential function.
- Kurtosis - based on the fourth-order cumulant.
The algorithm performs data centering and whitening (via eigenvalue decomposition of the covariance matrix) before applying the fixed-point iterations. Each independent component is orthogonalized against previously found components using deflation.
The nested Options record encapsulates hyperparameters (contrast function, max iterations, tolerance) and supports serialization to/from Properties.
Usage
Use ICA for blind source separation problems such as the cocktail party problem, artifact removal in EEG/MEG signals, feature extraction, or any scenario where you need to decompose observed mixed signals into independent source signals. At least N observations are needed to recover N independent sources.
Code Reference
Source Location
- Repository: Haifengl_Smile
- File: base/src/main/java/smile/ica/ICA.java
- Lines: 1-310
Signature
public record ICA(double[][] components) implements Serializable {
// Nested Options record
public record Options(DifferentiableFunction contrast, int maxIter, double tol) {
public Options(DifferentiableFunction contrast, int maxIter);
public Options(String contrast, int maxIter);
public Properties toProperties();
public static Options of(Properties props) throws ReflectiveOperationException;
}
// Fitting methods
public static ICA fit(double[][] data, int p);
public static ICA fit(double[][] data, int p, Options options);
}
Import
import smile.ica.ICA;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| data | double[][] | Yes | Training data matrix. Rows correspond to source signals (observations), columns correspond to samples. |
| p | int | Yes | The number of independent components to extract (1 <= p <= number of rows in data). |
| options | ICA.Options | No | Hyperparameters: contrast function (default LogCosh), maxIter (default 100), tolerance (default 1E-4). |
Outputs
| Name | Type | Description |
|---|---|---|
| ICA | ICA | The fitted ICA model. |
| components() | double[][] | The independent components. Each row is an independent component vector. |
Usage Examples
Basic Usage
import smile.ica.ICA;
// Mixed signals: rows are observations, columns are time samples
double[][] mixedSignals = new double[3][1000];
// ... populate with mixed signal data ...
// Fit ICA with 3 independent components using default LogCosh contrast
ICA ica = ICA.fit(mixedSignals, 3);
// Access the separated components
double[][] components = ica.components();
// components[0], components[1], components[2] are the independent sources
With Custom Options
import smile.ica.ICA;
// Configure with Gaussian contrast function, 200 iterations, tolerance 1E-5
ICA.Options options = new ICA.Options("Gaussian", 200);
double[][] data = new double[4][5000];
// ... populate data ...
ICA ica = ICA.fit(data, 2, options);
double[][] components = ica.components();
Persistence with Properties
import smile.ica.ICA;
import java.util.Properties;
// Save options to properties
ICA.Options options = new ICA.Options("LogCosh", 100);
Properties props = options.toProperties();
// Restore options from properties
ICA.Options restored = ICA.Options.of(props);