From 4ee03f09ffce2f0b775f13ef5faff08ef16b1c0f Mon Sep 17 00:00:00 2001
From: Phil Steitz
Date: Sun, 21 Jun 2009 02:22:09 +0000
Subject: [PATCH] Added Spearman's correlation.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@786940 13f79535-47bb-0310-9956-ffa450edef68
---
src/site/xdoc/userguide/stat.xml | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/src/site/xdoc/userguide/stat.xml b/src/site/xdoc/userguide/stat.xml
index 4abbdc499..953e97be7 100644
--- a/src/site/xdoc/userguide/stat.xml
+++ b/src/site/xdoc/userguide/stat.xml
@@ -543,9 +543,11 @@ new NaturalRanking(NaNStrategy.REMOVED,TiesStrategy.SEQUENTIAL).rank(exampleData
org.apache.commons.math.stat.correlation package computes covariances
and correlations for pairs of arrays or columns of a matrix.
- Covariance computes covariances and
+ Covariance computes covariances,
- PearsonsCorrelation provides Pearson's Product-Moment correlation coefficients.
+ PearsonsCorrelation provides Pearson's Product-Moment correlation coefficients and
+
+ SpearmansCorrelation computes Spearman's rank correlation.
Implementation Notes
@@ -560,12 +562,19 @@ new NaturalRanking(NaNStrategy.REMOVED,TiesStrategy.SEQUENTIAL).rank(exampleData
defaults to true.
-
+
PearsonsCorrelation computes correlations defined by the formula cor(X, Y) = sum[(xi - E(X))(yi - E(Y))] / [(n - 1)s(X)s(Y)]
where E(X) and E(Y) are means of X and Y
and s(X), s(Y) are standard deviations.
+
+
+ SpearmansCorrelation applies a rank transformation to the input data and computes Pearson's
+ correlation on the ranked data. The ranking algorithm is configurable. By default,
+
+ NaturalRanking with default strategies for handling ties and NaN values is used.
+
@@ -657,6 +666,20 @@ new PearsonsCorrelation(data).getCorrelationPValues().getEntry(0,1)
between the two columns of data is significant at the 99% level.
+
Spearman's rank correlation coefficient
+
+
To compute the Spearman's rank-moment correlation between two double arrays
+ x and y:
+
+ This is equivalent to
+
+