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 Details

    • PearsonsSampleCorrelationCoefficient

      public PearsonsSampleCorrelationCoefficient()
  • Method Details

    • calculateRankCorrelation

      public double calculateRankCorrelation(double[] x, double[] y)
      Calculates the Pearson sample correlation coefficient for the two given, paired samples.
      Specified by:
      calculateRankCorrelation in interface RankCorrelationCalculator
      Parameters:
      x - the x samples
      y - 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 where x != NaN and y != NaN.
      Parameters:
      x - the x samples
      y - 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 have x != NaN and y != NaN. The returned array contains the average x as first and the average y as second element.
      Parameters:
      x - the x samples
      y - 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 samples
      y - the y samples
      Returns:
      the variances and covariance of x and y.