public class PearsonCorrelation
extends java.lang.Object
CovarianceMatrix
which uses
slightly more memory (by using arrays) but essentially does the same.Modifier and Type | Field and Description |
---|---|
private double |
sumWe
Weight sum.
|
private double |
sumX
Current mean for X and Y.
|
private double |
sumXX
Aggregation for squared residuals - we are not using sum-of-squares!
|
private double |
sumXY
Aggregation for squared residuals - we are not using sum-of-squares!
|
private double |
sumY
Current mean for X and Y.
|
private double |
sumYY
Aggregation for squared residuals - we are not using sum-of-squares!
|
Constructor and Description |
---|
PearsonCorrelation()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static double |
coefficient(double[] x,
double[] y)
Compute the Pearson product-moment correlation coefficient for two
FeatureVectors.
|
static double |
coefficient(NumberVector x,
NumberVector y)
Compute the Pearson product-moment correlation coefficient for two
NumberVectors.
|
double |
getCorrelation()
Get the Pearson correlation value.
|
double |
getCount()
Get the number of points the average is based on.
|
double |
getMeanX()
Return mean of X
|
double |
getMeanY()
Return mean of Y
|
double |
getNaiveCovariance()
Get the covariance of X and Y (not taking sampling into account)
|
double |
getNaiveStddevX()
Return standard deviation using the non-sample variance
Note: usually, you should be using
getSampleStddevX() instead! |
double |
getNaiveStddevY()
Return standard deviation using the non-sample variance
Note: usually, you should be using
getSampleStddevY() instead! |
double |
getNaiveVarianceX()
Return the naive variance (not taking sampling into account)
Note: usually, you should be using
getSampleVarianceX() instead! |
double |
getNaiveVarianceY()
Return the naive variance (not taking sampling into account)
Note: usually, you should be using
getSampleVarianceY() instead! |
double |
getSampleCovariance()
Get the covariance of X and Y (with sampling correction)
|
double |
getSampleStddevX()
Return standard deviation
|
double |
getSampleStddevY()
Return standard deviation
|
double |
getSampleVarianceX()
Return sample variance.
|
double |
getSampleVarianceY()
Return sample variance.
|
void |
put(double x,
double y)
Put a single value into the correlation statistic.
|
void |
put(double x,
double y,
double w)
Put a single value into the correlation statistic.
|
void |
reset()
Reset the value.
|
static double |
weightedCoefficient(double[] x,
double[] y,
double[] weights)
Compute the Pearson product-moment correlation coefficient for two
FeatureVectors.
|
static double |
weightedCoefficient(NumberVector x,
NumberVector y,
double[] weights)
Compute the Pearson product-moment correlation coefficient for two
NumberVectors.
|
static double |
weightedCoefficient(NumberVector x,
NumberVector y,
NumberVector weights)
Compute the Pearson product-moment correlation coefficient for two
FeatureVectors.
|
private double sumXX
private double sumYY
private double sumXY
private double sumX
private double sumY
private double sumWe
public void put(double x, double y, double w)
x
- Value in Xy
- Value in Yw
- Weightpublic void put(double x, double y)
x
- Value in Xy
- Value in Ypublic double getCorrelation()
public double getCount()
public double getMeanX()
public double getMeanY()
public double getNaiveCovariance()
public double getSampleCovariance()
public double getNaiveVarianceX()
getSampleVarianceX()
instead!public double getSampleVarianceX()
public double getNaiveStddevX()
getSampleStddevX()
instead!public double getSampleStddevX()
public double getNaiveVarianceY()
getSampleVarianceY()
instead!public double getSampleVarianceY()
public double getNaiveStddevY()
getSampleStddevY()
instead!public double getSampleStddevY()
public void reset()
public static double coefficient(double[] x, double[] y)
x
- first FeatureVectory
- second FeatureVectorpublic static double coefficient(NumberVector x, NumberVector y)
x
- first NumberVectory
- second NumberVectorpublic static double weightedCoefficient(double[] x, double[] y, double[] weights)
x
- first FeatureVectory
- second FeatureVectorweights
- Weightspublic static double weightedCoefficient(NumberVector x, NumberVector y, double[] weights)
x
- first NumberVectory
- second NumberVectorweights
- Weightspublic static double weightedCoefficient(NumberVector x, NumberVector y, NumberVector weights)
x
- first FeatureVectory
- second FeatureVectorweights
- WeightsCopyright © 2019 ELKI Development Team. License information.