Author: tn
Date: Sat Nov 10 16:51:49 2012
New Revision: 1407847
URL: http://svn.apache.org/viewvc?rev=1407847&view=rev
Log:
[MATH-892] Add new ctor to SpearmansCorrelation, reordering of ctors.
Modified:
commons/proper/math/trunk/src/changes/changes.xml
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/correlation/SpearmansCorrelation.java
Modified: commons/proper/math/trunk/src/changes/changes.xml
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/changes/changes.xml?rev=1407847&r1=1407846&r2=1407847&view=diff
==============================================================================
--- commons/proper/math/trunk/src/changes/changes.xml (original)
+++ commons/proper/math/trunk/src/changes/changes.xml Sat Nov 10 16:51:49 2012
@@ -52,6 +52,10 @@ If the output is not quite correct, chec
<body>
<release version="3.1" date="TBD" description="
">
+ <action dev="tn" type="add" issue="MATH-892">
+ Add new constructor to "SpearmansCorrelation" class which allows to
specify the
+ "RankingAlgorithm" to be used.
+ </action>
<action dev="luc" type="fix" issue="MATH-890">
Fixed naming inconsistencies between Interval and IntervalsSet classes.
</action>
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/correlation/SpearmansCorrelation.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/correlation/SpearmansCorrelation.java?rev=1407847&r1=1407846&r2=1407847&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/correlation/SpearmansCorrelation.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/correlation/SpearmansCorrelation.java
Sat Nov 10 16:51:49 2012
@@ -50,18 +50,21 @@ public class SpearmansCorrelation {
private final PearsonsCorrelation rankCorrelation;
/**
- * Create a SpearmansCorrelation with the given input data matrix
- * and ranking algorithm.
+ * Create a SpearmansCorrelation without data.
+ */
+ public SpearmansCorrelation() {
+ this(new NaturalRanking());
+ }
+
+ /**
+ * Create a SpearmansCorrelation with the given ranking algorithm.
*
- * @param dataMatrix matrix of data with columns representing
- * variables to correlate
* @param rankingAlgorithm ranking algorithm
*/
- public SpearmansCorrelation(final RealMatrix dataMatrix, final
RankingAlgorithm rankingAlgorithm) {
- this.data = dataMatrix.copy();
+ public SpearmansCorrelation(final RankingAlgorithm rankingAlgorithm) {
+ data = null;
this.rankingAlgorithm = rankingAlgorithm;
- rankTransform(data);
- rankCorrelation = new PearsonsCorrelation(data);
+ rankCorrelation = null;
}
/**
@@ -75,12 +78,18 @@ public class SpearmansCorrelation {
}
/**
- * Create a SpearmansCorrelation without data.
+ * Create a SpearmansCorrelation with the given input data matrix
+ * and ranking algorithm.
+ *
+ * @param dataMatrix matrix of data with columns representing
+ * variables to correlate
+ * @param rankingAlgorithm ranking algorithm
*/
- public SpearmansCorrelation() {
- data = null;
- this.rankingAlgorithm = new NaturalRanking();
- rankCorrelation = null;
+ public SpearmansCorrelation(final RealMatrix dataMatrix, final
RankingAlgorithm rankingAlgorithm) {
+ this.data = dataMatrix.copy();
+ this.rankingAlgorithm = rankingAlgorithm;
+ rankTransform(data);
+ rankCorrelation = new PearsonsCorrelation(data);
}
/**