[MATH-892] Add new ctor to SpearmansCorrelation, reordering of ctors.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1407847 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas Neidhart 2012-11-10 16:51:49 +00:00
parent a170601629
commit ff96ac9292
2 changed files with 26 additions and 13 deletions

View File

@ -52,6 +52,10 @@ If the output is not quite correct, check for invisible trailing spaces!
<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>

View File

@ -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);
}
/**