Class PearsonsSampleCorrelationCoefficient
- java.lang.Object
-
- org.aksw.palmetto.evaluate.correlation.PearsonsSampleCorrelationCoefficient
-
- All Implemented Interfaces:
RankCorrelationCalculator
public class PearsonsSampleCorrelationCoefficient extends Object implements RankCorrelationCalculator
Class implementing Pearsons sample correlation coefficient for two given, paired samples.- Author:
- Michael Röder (michael.roeder@uni-paderborn.de)
-
-
Constructor Summary
Constructors Constructor Description PearsonsSampleCorrelationCoefficient()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected double[]calculateCoVariances(double[] x, double avgX, double[] y, double avgY)Calculates the variance and covariance for all valid (x,y) pairs.protected double[]calculatePairedAverage(double[] x, double[] y)Calculates the average values of the given (x,y) pairs for all pairs that havex != NaNandy != NaN.doublecalculateRankCorrelation(double[] x, double[] y)Calculates the Pearson sample correlation coefficient for the two given, paired samples.protected intcountValidPairs(double[] x, double[] y)Counts the number of valid pairs (x,y) , i.e., pairs wherex != NaNandy != NaN.
-
-
-
Method Detail
-
calculateRankCorrelation
public double calculateRankCorrelation(double[] x, double[] y)Calculates the Pearson sample correlation coefficient for the two given, paired samples.- Specified by:
calculateRankCorrelationin interfaceRankCorrelationCalculator- Parameters:
x- the x samplesy- the y samples- Returns:
- Parsons sample correlation coefficient
- Throws:
IllegalArgumentException- if x and y have not the same size or have less than 2 elements.
-
countValidPairs
protected int countValidPairs(double[] x, double[] y)Counts the number of valid pairs (x,y) , i.e., pairs wherex != NaNandy != NaN.- Parameters:
x- the x samplesy- the y samples- Returns:
- the number of valid pairs
-
calculatePairedAverage
protected double[] calculatePairedAverage(double[] x, double[] y)Calculates the average values of the given (x,y) pairs for all pairs that havex != NaNandy != NaN. The returned array contains the average x as first and the average y as second element.- Parameters:
x- the x samplesy- the y samples- Returns:
- the averages of x and y.
-
calculateCoVariances
protected double[] calculateCoVariances(double[] x, double avgX, double[] y, double avgY)Calculates the variance and covariance for all valid (x,y) pairs. The returned array contains the variance of x as first, the variance of y as second and their covariance as third element.- Parameters:
x- the x samplesy- the y samples- Returns:
- the variances and covariance of x and y.
-
-