commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1086057 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/stat/correlation/PearsonsCorrelation.java test/java/org/apache/commons/math/stat/correlation/PearsonsCorrelationTest.java
Date Sun, 27 Mar 2011 22:06:19 GMT
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);

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/correlation/PearsonsCorrelationTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/correlation/PearsonsCorrelationTest.java?rev=1086057&r1=1086056&r2=1086057&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/correlation/PearsonsCorrelationTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/stat/correlation/PearsonsCorrelationTest.java
Sun Mar 27 22:06:18 2011
@@ -194,7 +194,7 @@ public class PearsonsCorrelationTest {
     public void testConstant() {
         double[] noVariance = new double[] {1, 1, 1, 1};
         double[] values = new double[] {1, 2, 3, 4};
-        Assert.assertTrue(Double.isNaN(new PearsonsCorrelation().correlation(noVariance,
values)));
+        Assert.assertTrue(Double.isNaN(PearsonsCorrelation.correlation(noVariance, values)));
     }
 
 
@@ -207,7 +207,7 @@ public class PearsonsCorrelationTest {
         double[] one = new double[] {1};
         double[] two = new double[] {2};
         try {
-            new PearsonsCorrelation().correlation(one, two);
+            PearsonsCorrelation.correlation(one, two);
             Assert.fail("Expecting IllegalArgumentException");
         } catch (IllegalArgumentException ex) {
             // Expected
@@ -277,7 +277,7 @@ public class PearsonsCorrelationTest {
         double[][] data = matrix.getData();
         double[] x = matrix.getColumn(0);
         double[] y = matrix.getColumn(1);
-        Assert.assertEquals(new PearsonsCorrelation().correlation(x, y),
+        Assert.assertEquals(PearsonsCorrelation.correlation(x, y),
                 corrInstance.getCorrelationMatrix().getEntry(0, 1), Double.MIN_VALUE);
         TestUtils.assertEquals("Correlation matrix", corrInstance.getCorrelationMatrix(),
                 new PearsonsCorrelation().computeCorrelationMatrix(data), Double.MIN_VALUE);



Mime
View raw message