Class FastIca

java.lang.Object
edu.cmu.tetrad.search.FastIca

public class FastIca extends Object
FastICA (real-valued) translated for Tetrad.

Key stability fixes: - Correct derivative in symmetric (parallel) update: g'(u) = α(1 - g(u)^2) for logcosh. - Whitening ridge (eps) to avoid exploding 1/sqrt(λ) on tiny eigenvalues. - Orthonormalize random wInit via SVD (helps convergence). - Small deflation loop fix (row assignment index).

Reference: Hyvarinen & Oja (2000) Independent Component Analysis: Algorithms and Applications. Neural Networks 13(4–5):411–430.

Version:
$Id: $Id
Author:
josephramsey
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    A record that represents the result of the Independent Component Analysis (ICA) process.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static int
    Extract components one-at-a-time.
    static int
    Neg-entropy nonlinearity: exp.
    static int
    Neg-entropy nonlinearity: logcosh.
    static int
    Extract components simultaneously (symmetric decorrelation).
  • Constructor Summary

    Constructors
    Constructor
    Description
    FastIca(Matrix X, int numComponents)
    Constructs a FastIca object with the given data matrix and number of components.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Centers the rows of the given matrix by subtracting the mean of each row from its elements.
    Run FastICA and return preprocessed X, whitening K, unmixing W, and sources S.
    void
    setAlgorithmType(int algorithmType)
    Sets the algorithm type to be used in the FastICA computation.
    void
    setAlpha(double alpha)
    Sets the alpha parameter for the FastICA algorithm.
    void
    setFunction(int function)
    Sets the function to be used for the ICA algorithm.
    void
    setMaxIterations(int maxIterations)
    Sets the maximum number of iterations for the FastICA algorithm.
    void
    setRowNorm(boolean rowNorm)
    Sets whether row normalization should be applied.
    void
    setTolerance(double tolerance)
    Sets the tolerance value for convergence in the FastICA algorithm.
    void
    setVerbose(boolean verbose)
    Enables or disables verbose mode for the FastICA algorithm.
    void
    Sets the initial weights matrix to be used for the FastICA algorithm.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • PARALLEL

      public static int PARALLEL
      Extract components simultaneously (symmetric decorrelation).
    • DEFLATION

      public static int DEFLATION
      Extract components one-at-a-time.
    • LOGCOSH

      public static int LOGCOSH
      Neg-entropy nonlinearity: logcosh.
    • EXP

      public static int EXP
      Neg-entropy nonlinearity: exp.
  • Constructor Details

    • FastIca

      public FastIca(Matrix X, int numComponents)
      Constructs a FastIca object with the given data matrix and number of components.
      Parameters:
      X - The input data matrix where each row represents a signal and each column is a feature.
      numComponents - The number of independent components to extract from the input data.
  • Method Details

    • center

      public static void center(Matrix x)
      Centers the rows of the given matrix by subtracting the mean of each row from its elements. This operation adjusts the data so that each row has a mean value of zero.
      Parameters:
      x - The input matrix to be centered. Each row will have its mean value subtracted from its elements.
    • setAlgorithmType

      public void setAlgorithmType(int algorithmType)
      Sets the algorithm type to be used in the FastICA computation. The algorithm type determines the approach for extracting independent components and must be either DEFLATION or PARALLEL.
      Parameters:
      algorithmType - the type of algorithm to use. Acceptable values are FastIca.DEFLATION for the deflation approach or FastIca.PARALLEL for the parallel approach.
      Throws:
      IllegalArgumentException - if the value is not DEFLATION or PARALLEL.
    • setFunction

      public void setFunction(int function)
      Sets the function to be used for the ICA algorithm. The function determines the non-linear processing applied during the computation. Acceptable values are FastIca.LOGCOSH or FastIca.EXP.
      Parameters:
      function - The non-linear function type to be used. Must be either LOGCOSH or EXP.
      Throws:
      IllegalArgumentException - if the value is not FastIca.LOGCOSH or FastIca.EXP.
    • setAlpha

      public void setAlpha(double alpha)
      Sets the alpha parameter for the FastICA algorithm. The alpha parameter influences the non-linearity used during computation and must be within the range [1, 2].
      Parameters:
      alpha - The value to set for the alpha parameter. Must be within the range [1, 2].
      Throws:
      IllegalArgumentException - if the provided alpha value is outside the range [1, 2].
    • setRowNorm

      public void setRowNorm(boolean rowNorm)
      Sets whether row normalization should be applied. Row normalization adjusts the rows of the data matrix to ensure uniform scaling.
      Parameters:
      rowNorm - A boolean value indicating whether row normalization is enabled (true) or disabled (false).
    • setMaxIterations

      public void setMaxIterations(int maxIterations)
      Sets the maximum number of iterations for the FastICA algorithm. The algorithm will terminate if the maximum number of iterations is reached before convergence.
      Parameters:
      maxIterations - the maximum number of iterations to be set. It must be a positive integer.
    • setTolerance

      public void setTolerance(double tolerance)
      Sets the tolerance value for convergence in the FastICA algorithm. This determines the threshold for stopping the iterative process based on the change in component values. The tolerance must be a positive value.
      Parameters:
      tolerance - The convergence tolerance to be set. Must be a positive value.
    • setVerbose

      public void setVerbose(boolean verbose)
      Enables or disables verbose mode for the FastICA algorithm. When verbose mode is enabled, detailed information about the algorithm's progress and intermediate steps may be logged or displayed.
      Parameters:
      verbose - A boolean value indicating whether verbose mode is enabled (true) or disabled (false).
    • setWInit

      public void setWInit(Matrix wInit)
      Sets the initial weights matrix to be used for the FastICA algorithm.
      Parameters:
      wInit - The initial weights matrix. This matrix is used as the starting point for the algorithm to compute the independent components.
    • findComponents

      public FastIca.IcaResult findComponents()
      Run FastICA and return preprocessed X, whitening K, unmixing W, and sources S.
      Returns:
      IcaResult containing preprocessed X, whitening K, unmixing W, and sources S.