[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> <body>
<release version="3.1" date="TBD" description=" <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"> <action dev="luc" type="fix" issue="MATH-890">
Fixed naming inconsistencies between Interval and IntervalsSet classes. Fixed naming inconsistencies between Interval and IntervalsSet classes.
</action> </action>

View File

@ -50,18 +50,21 @@ public class SpearmansCorrelation {
private final PearsonsCorrelation rankCorrelation; private final PearsonsCorrelation rankCorrelation;
/** /**
* Create a SpearmansCorrelation with the given input data matrix * Create a SpearmansCorrelation without data.
* and ranking algorithm. */
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 * @param rankingAlgorithm ranking algorithm
*/ */
public SpearmansCorrelation(final RealMatrix dataMatrix, final RankingAlgorithm rankingAlgorithm) { public SpearmansCorrelation(final RankingAlgorithm rankingAlgorithm) {
this.data = dataMatrix.copy(); data = null;
this.rankingAlgorithm = rankingAlgorithm; this.rankingAlgorithm = rankingAlgorithm;
rankTransform(data); rankCorrelation = null;
rankCorrelation = new PearsonsCorrelation(data);
} }
/** /**
@ -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() { public SpearmansCorrelation(final RealMatrix dataMatrix, final RankingAlgorithm rankingAlgorithm) {
data = null; this.data = dataMatrix.copy();
this.rankingAlgorithm = new NaturalRanking(); this.rankingAlgorithm = rankingAlgorithm;
rankCorrelation = null; rankTransform(data);
rankCorrelation = new PearsonsCorrelation(data);
} }
/** /**