algorithms

## Class KendallTauRankCorrelation<T extends RealType<T>>

• Type Parameters:
`T` -

```public class KendallTauRankCorrelation<T extends RealType<T>>
extends Algorithm<T>```
This algorithm calculates Kendall's Tau-b rank correlation coefficient

According to http://en.wikipedia.org/wiki/Kendall_tau_rank_correlation_coefficient, Tau-b (appropriate if multiple pairs share the same first, or second, value), the rank correlation of a set of pairs (x_1, y_1), ..., (x_n, y_n):

``` Tau_B = (n_c - n_d) / sqrt( (n_0 - n_1) (n_0 - n_2) )
```
where
``` n_0 = n (n - 1) / 2
n_1 = sum_i t_i (t_i - 1) / 2
n_2 = sum_j u_j (u_j - 1) / 2
n_c = #{ i, j; i != j && (x_i - x_j) * (y_i - y_j) > 0 },
i.e. the number of pairs of pairs agreeing on the order of x and y, respectively
n_d = #{ i, j: i != j && (x_i - x_j) * (y_i - y_j) < 0 },
i.e. the number of pairs of pairs where x and y are ordered opposite of each other
t_i = number of tied values in the i-th group of ties for the first quantity
u_j = number of tied values in the j-th group of ties for the second quantity
```

Author:
Johannes Schindelin

• ### Fields inherited from class algorithms.Algorithm

`name`
• ### Constructor Summary

Constructors
Constructor and Description
`KendallTauRankCorrelation()`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static <T extends RealType<T>>double` `calculateMergeSort(PairIterator<T> iterator)`
Calculate Tau-b efficiently.
`static <T extends RealType<T>>double` `calculateNaive(PairIterator<T> iterator)`
`void` `execute(DataContainer<T> container)`
Executes the previously initialized `Algorithm`.
`void` `processResults(ResultHandler<T> handler)`
A method to give the algorithm the opportunity to let its results being processed by the passed handler.
• ### Methods inherited from class algorithms.Algorithm

`addWarning, getName, getWarnings`
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Constructor Detail

• #### KendallTauRankCorrelation

`public KendallTauRankCorrelation()`
• ### Method Detail

• #### execute

```public void execute(DataContainer<T> container)
throws MissingPreconditionException```
Description copied from class: `Algorithm`
Executes the previously initialized `Algorithm`.
Specified by:
`execute` in class `Algorithm<T extends RealType<T>>`
Throws:
`MissingPreconditionException`
• #### calculateNaive

`public static <T extends RealType<T>> double calculateNaive(PairIterator<T> iterator)`
• #### calculateMergeSort

`public static <T extends RealType<T>> double calculateMergeSort(PairIterator<T> iterator)`
Calculate Tau-b efficiently.

This implementation is based on this description of the merge sort based way to calculate Tau-b: http://en.wikipedia.org/wiki/Kendall_tau_rank_correlation_coefficient #Algorithms. This is supposed to be the method described in:

Knight, W. (1966). "A Computer Method for Calculating Kendall's Tau with Ungrouped Data". Journal of the American Statistical Association 61 (314): 436–439. doi:10.2307/2282833.
but since that article is not available as Open Access, it is unnecessarily hard to verify.

Parameters:
`iterator` - the iterator of the pairs
Returns:
Tau-b
• #### processResults

`public void processResults(ResultHandler<T> handler)`
Description copied from class: `Algorithm`
A method to give the algorithm the opportunity to let its results being processed by the passed handler. By default this methods passes the collected warnings to the handler and sub-classes should make use of this by adding custom behavior and call the super class.
Overrides:
`processResults` in class `Algorithm<T extends RealType<T>>`
Parameters:
`handler` - The ResultHandler to process the results.