Class DistributionComparator
public final class DistributionComparator
extends java.lang.Object
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 Summary
Constructors Constructor Description DistributionComparator()
Constructs an emptyDistributionComparator
object.DistributionComparator(EmpiricalDistribution x, EmpiricalDistribution y)
Constructs aDistributionComparator
object with specified X and Y sequences and compares them. -
Method Summary
Modifier and Type Method Description double
getCovariance()
Getter method for the covariance.double
getEQC()
Getter method for the equality coefficient (EQC).double
getMAE()
Getter method for the mean absolute error (MAE).double
getMAPE()
Getter method for the mean absolute percent error (MAPE).double
getMAXE()
Getter method for the maximum error (MAXE).double
getME()
Getter method for the mean error (ME).double
getMRE()
Getter method for the mean relative error (MRE).double
getMSE()
Getter method for the mean square error (MSE).int
getN()
Getter method for the number of values per sequence.double
getPearsonCorrelation()
Getter method for Pearson's correlation coefficient.double
getRMSE()
Getter method for the root mean square error (RMSE).double
getRMSEP()
Getter method for the root mean square error proportional (RMSEP).double
getRRMSE()
Getter method for the relative root mean square error (RRMSE).double
getSSE()
Getter method for the sum of square errors (SSE).EmpiricalDistribution
getXData()
Getter method for the X sequence.EmpiricalDistribution
getYData()
Getter method for the Y sequence.static boolean
performKolmogorovSmirnovTest(EmpiricalDistribution x, EmpiricalDistribution y, double alpha)
Peforms a Kolmogorov-Smirnov (KS) test on 2 sequences (they can have different lengths).void
setData(EmpiricalDistribution x, EmpiricalDistribution y)
Loads specific X and Y sequences and compares them.void
setXData(EmpiricalDistribution x)
Loads a specific X sequence and compares them.void
setYData(EmpiricalDistribution y)
Loads a specific Y sequence and compares them.Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
DistributionComparator
public DistributionComparator()Constructs an emptyDistributionComparator
object. -
DistributionComparator
Constructs aDistributionComparator
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 sequencey
- the Y sequence
-
-
Method Details
-
getXData
Getter method for the X sequence.- Returns:
- the X sequence
-
getYData
Getter method for the Y sequence.- Returns:
- the Y sequence
-
setData
Loads specific X and Y sequences and compares them.Note that both sequences should have the same number of values.
- Parameters:
x
- the X sequencey
- the Y sequence
-
setXData
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
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 sequencey
- the Y sequencealpha
- 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)
-