procope.tools.math
Class SpearmanCoefficient

java.lang.Object
  extended by procope.tools.math.SpearmanCoefficient
All Implemented Interfaces:
CorrelationCoefficient

public class SpearmanCoefficient
extends Object
implements CorrelationCoefficient

Implements Spearman's rank correlation coefficient to calulate the correlation between two given rows of data points. It is defined as the Pearson coefficient of the rankings of both data rows.

Author:
Jan Krumsiek

Constructor Summary
SpearmanCoefficient()
          Creates the Spearman rank coefficient object.
 
Method Summary
 void feedData(Collection<Point> data)
          Feeds a list of data points into the dataset.
 void feedData(float x, float y)
          Feeds one data point into the dataset
 void feedData(Point p)
          Feeds one data point into the dataset
 float getCorrelationCoefficient()
          Calculates Scorrelation coefficient for the current dataset.
static float[] rankArray(Comparable<?>[] data)
          Calculates the ranking for a given array of comparable objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpearmanCoefficient

public SpearmanCoefficient()
Creates the Spearman rank coefficient object.

Method Detail

feedData

public void feedData(float x,
                     float y)
Description copied from interface: CorrelationCoefficient
Feeds one data point into the dataset

Specified by:
feedData in interface CorrelationCoefficient
Parameters:
x - data point's x
y - data point's y

feedData

public void feedData(Collection<Point> data)
Description copied from interface: CorrelationCoefficient
Feeds a list of data points into the dataset.

Specified by:
feedData in interface CorrelationCoefficient
Parameters:
data - list of points.

feedData

public void feedData(Point p)
Description copied from interface: CorrelationCoefficient
Feeds one data point into the dataset

Specified by:
feedData in interface CorrelationCoefficient
Parameters:
p - data point to be added

getCorrelationCoefficient

public float getCorrelationCoefficient()
Calculates Scorrelation coefficient for the current dataset.

Specified by:
getCorrelationCoefficient in interface CorrelationCoefficient
Returns:
correlation coefficient of current list of data points

rankArray

public static float[] rankArray(Comparable<?>[] data)
Calculates the ranking for a given array of comparable objects. This ranking contains ascending integer numbers in the natural ordering of the objects. Equal objects get averaged ranks. Note that a sorting step is required to calculate this ranking, thus the time complexity of the whole ranking process is O(n2).

Parameters:
data - array of comparable objects to be ranked
Returns:
ranking array for the given input array