On Sun, Mar 27, 2011 at 05:25:59PM -0700, Phil Steitz wrote:
> I would prefer not to make that method static, since that means it
> cannot be overridden and it is used internally in this class as well
> as Spearman's. If we want to provide a convenience method with
> static signature, we should add it to StatUtils or create a
> CorrelationUtils class to bundle static methods such as this and
> similar for Covariance, Spearman's etc.
>
> Phil
>
> On 3/27/11 3:06 PM, [email protected] wrote:
> > Author: erans
> > Date: Sun Mar 27 22:06:18 2011
> > New Revision: 1086057
> >
> > URL: http://svn.apache.org/viewvc?rev=1086057&view=rev
> > Log:
> > MATH-549
> > Method can be "static".
> >
> > Modified:
> >
> > commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/correlation/PearsonsCorrelation.java
> >
> > commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/correlation/PearsonsCorrelationTest.java
> >
> > Modified:
> > commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/correlation/PearsonsCorrelation.java
> > URL:
> > http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/correlation/PearsonsCorrelation.java?rev=1086057&r1=1086056&r2=1086057&view=diff
> > ==============================================================================
> > ---
> > commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/correlation/PearsonsCorrelation.java
> > (original)
> > +++
> > commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/correlation/PearsonsCorrelation.java
> > Sun Mar 27 22:06:18 2011
> > @@ -225,7 +225,8 @@ public class PearsonsCorrelation {
> > * @throws IllegalArgumentException if the arrays lengths do not
> > match or
> > * there is insufficient data
> > */
> > - public double correlation(final double[] xArray, final double[]
> > yArray) throws IllegalArgumentException {
> > + public static double correlation(final double[] xArray, final double[]
> > yArray)
> > + throws IllegalArgumentException {
> > SimpleRegression regression = new SimpleRegression();
> > if (xArray.length != yArray.length) {
> > throw new DimensionMismatchException(xArray.length,
> > yArray.length);
As is, it is not clear (from a design point-of-view) that it would make
sense to override the method (hence the legitimate request to make it
static). If polymorphism is really the intention, I think that it would
be worth adding an interface ("Correlation" maybe?).
Gilles
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]