Class GMM

All Implemented Interfaces:
Serializable, Copyable

public class GMM extends ContinuousDistribution implements Serializable
A Gaussian Mixture Model (GMM) distribution. This class represents a mixture of normal distributions, where each component has a weight, mean, and standard deviation.
See Also:
  • Constructor Details

    • GMM

      public GMM(double[] weights, double[] means, double[] sigmas)
      Creates a GMM with specified components.
      Parameters:
      weights - array of component weights (must sum to 1)
      means - array of component means
      sigmas - array of component standard deviations
  • Method Details

    • fromMatrix

      public static GMM fromMatrix(Matrix sgmm)
      Creates a GMM from a simplified matrix representation. Each row contains [weight, mean, sigma].
    • toMatrix

      public Matrix toMatrix()
      Converts this GMM to a simplified matrix representation. Each row contains [weight, mean, variance].
    • getMean

      public double getMean()
      Description copied from class: Distribution
      Gets the mean (expected value) of this distribution.
      Specified by:
      getMean in class Distribution
      Returns:
      the mean value
    • getVar

      public double getVar()
      Description copied from class: Distribution
      Gets the variance of this distribution. Computed as SCV * mean^2.
      Overrides:
      getVar in class Distribution
      Returns:
      the variance
    • getSCV

      public double getSCV()
      Description copied from class: Distribution
      Gets the squared coefficient of variation (SCV) of this distribution. SCV = Var(X) / E[X]^2.
      Specified by:
      getSCV in class Distribution
      Returns:
      the squared coefficient of variation
    • getSkewness

      public double getSkewness()
      Description copied from class: Distribution
      Gets the skewness of this distribution. Skewness measures the asymmetry of the probability distribution.
      Specified by:
      getSkewness in class Distribution
      Returns:
      the skewness value
    • evalCDF

      public double evalCDF(double x)
      Description copied from class: Distribution
      Evaluates the cumulative distribution function (CDF) at the given point.
      Specified by:
      evalCDF in class Distribution
      Parameters:
      x - the point at which to evaluate the CDF
      Returns:
      the CDF value at point t
    • evalPDF

      public double evalPDF(double x)
    • evalLST

      public double evalLST(double s)
      Description copied from class: Distribution
      Evaluate the Laplace-Stieltjes Transform at s
      Specified by:
      evalLST in class ContinuousDistribution
      Parameters:
      s - the Laplace domain variable
      Returns:
      the LST value at s
    • sample

      public double[] sample(int n)
      Description copied from class: Distribution
      Generates random samples from this distribution using default random generator.
      Overrides:
      sample in class Distribution
      Parameters:
      n - the number of samples to generate
      Returns:
      array of random samples
    • sample

      public double[] sample(int n, Random random)
      Description copied from class: Distribution
      Generates random samples from this distribution using the specified random generator.
      Specified by:
      sample in class Distribution
      Parameters:
      n - the number of samples to generate
      random - the random number generator to use
      Returns:
      array of random samples
    • convolve

      public GMM convolve(GMM other)
      Creates a new GMM by convolving this GMM with another GMM. Convolution corresponds to the sum of two independent random variables.
    • mixture

      public static GMM mixture(GMM gmm1, GMM gmm2, double p1, double p2)
      Creates a mixture of two GMMs with specified weights.
    • merge

      public GMM merge(int i, int j)
      Merges two components into one using moment matching.
    • autoMerge

      public GMM autoMerge(int k)
      Automatically merges components to reduce the GMM to k components.
    • getNumberOfComponents

      public int getNumberOfComponents()
    • getWeights

      public double[] getWeights()
    • getMeans

      public double[] getMeans()
    • getSigmas

      public double[] getSigmas()
    • getProcess

      public MatrixCell getProcess()
      Description copied from class: ContinuousDistribution
      Gets the process representation with actual distribution parameters. Returns a MatrixCell containing the distribution parameters.
      Specified by:
      getProcess in class ContinuousDistribution
      Returns:
      MatrixCell with distribution-specific parameters
    • toString

      public String toString()
      Overrides:
      toString in class Object