Class DistributionComparator

java.lang.Object
org.sm.smtools.math.statistics.DistributionComparator

public final class DistributionComparator
extends java.lang.Object
The DistributionComparator class offers various statistics to compare two empirical distributions based on their sequences of values.

Note that this class cannot be subclassed!

Version:
01/05/2014
Author:
Sven Maerivoet
  • Constructor Details

    • DistributionComparator

      public DistributionComparator()
      Constructs an empty DistributionComparator object.
    • DistributionComparator

      public DistributionComparator​(EmpiricalDistribution x, EmpiricalDistribution y)
      Constructs a DistributionComparator object with specified X and Y sequences and compares them.

      Note that both sequences should have the same number of values.

      Parameters:
      x - the X sequence
      y - the Y sequence
  • Method Details

    • getXData

      public EmpiricalDistribution getXData()
      Getter method for the X sequence.
      Returns:
      the X sequence
    • getYData

      public EmpiricalDistribution getYData()
      Getter method for the Y sequence.
      Returns:
      the Y sequence
    • setData

      public void setData​(EmpiricalDistribution x, EmpiricalDistribution y)
      Loads specific X and Y sequences and compares them.

      Note that both sequences should have the same number of values.

      Parameters:
      x - the X sequence
      y - the Y sequence
    • setXData

      public void setXData​(EmpiricalDistribution x)
      Loads a specific X sequence and compares them.

      Note that it should have the same number of values as the Y sequence.

      Parameters:
      x - the X sequence
    • setYData

      public void setYData​(EmpiricalDistribution y)
      Loads a specific Y sequence and compares them.

      Note that it should have the same number of values as the X sequence.

      Parameters:
      y - the Y sequence
    • getN

      public int getN()
      Getter method for the number of values per sequence.
      Returns:
      the number of values per sequence
    • getMAE

      public double getMAE()
      Getter method for the mean absolute error (MAE).

      MAE = the mean of all absolute differences.

      MAE = (1 / N) * SUM |Xi - Yi|

      Returns:
      the MAE
    • getMSE

      public double getMSE()
      Getter method for the mean square error (MSE).

      MSE = the mean of all squared differences (more sensitive to large outliers).

      MSE = (1 / N) * SUM (Xi - Yi)^2

      Returns:
      the MSE
    • getRMSE

      public double getRMSE()
      Getter method for the root mean square error (RMSE).

      RMSE = SQRT(MSE)

      Returns:
      the RMSE
    • getSSE

      public double getSSE()
      Getter method for the sum of square errors (SSE).

      SSE = SUM (Xi - Yi)^2

      Returns:
      the SSE
    • getMRE

      public double getMRE()
      Getter method for the mean relative error (MRE).

      MRE = the mean absolute difference in relation to one of the values; becomes very large or infinite if values appear near or equal to 0.

      MRE = (1 / N) * SUM |Xi - Yi|/Xi

      Returns:
      the MRE
    • getRRMSE

      public double getRRMSE()
      Getter method for the relative root mean square error (RRMSE).

      RRMSE becomes very large or infinite if values appear near or equal to 0.

      RRMSE = SQRT[ (1 / N) * SUM [(Xi - Yi)/Xi]^2 ]

      Returns:
      the RRMSE
    • getRMSEP

      public double getRMSEP()
      Getter method for the root mean square error proportional (RMSEP).

      RMSEP = RMSE divided by the mean of the measures and avoids the problem of infinite values of the MRE.

      RMSEP = SQRT[ N * SUM (Xi - Yi)^2 ] / SUM Xi

      Returns:
      the RMSEP
    • getMAXE

      public double getMAXE()
      Getter method for the maximum error (MAXE).

      MAXE = upper bound of all differences.

      MAXE = MAX{ |Xi - Yi| }

      Returns:
      the MAXE
    • getME

      public double getME()
      Getter method for the mean error (ME).

      ME makes sense if positive and negative fluctuations equalise each other.

      ME = (1 / N) * SUM (Xi - Yi)

      Returns:
      the ME
    • getMAPE

      public double getMAPE()
      Getter method for the mean absolute percent error (MAPE).

      MAPE is the MRE in percent.

      MAPE = 100 * MRE

      Returns:
      the MAPE
    • getEQC

      public double getEQC()
      Getter method for the equality coefficient (EQC).

      EQC lies between 0 and 1; total equality results in EQC = 1.

      EQC = 1 - [ SQRT(SUM (Xn - Yn)^2 ) / [SQRT( SUM Xn ) + SQRT( SUM Yn )] ]

      Returns:
      the EQC
    • getCovariance

      public double getCovariance()
      Getter method for the covariance.
      Returns:
      the covariance
    • getPearsonCorrelation

      public double getPearsonCorrelation()
      Getter method for Pearson's correlation coefficient.
      Returns:
      Pearson's correlation coefficient
    • performKolmogorovSmirnovTest

      public static boolean performKolmogorovSmirnovTest​(EmpiricalDistribution x, EmpiricalDistribution y, double alpha)
      Peforms a Kolmogorov-Smirnov (KS) test on 2 sequences (they can have different lengths).
      Parameters:
      x - the X sequence
      y - the Y sequence
      alpha - the alpha value for the KS-test
      Returns:
      true when the H0 hypothesis is accepted (i.e. there is not enough evidence to conclude that X and Y are significantly different)