You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2016/05/31 00:48:19 UTC

[1/3] [math] Initialize at declaration.

Repository: commons-math
Updated Branches:
  refs/heads/develop e7c42ed0f -> fc9d93db6


Initialize at declaration.

Thanks to Dave Brosius.


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/633de29f
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/633de29f
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/633de29f

Branch: refs/heads/develop
Commit: 633de29fedf11544f2c3d5052890cb014e612bd5
Parents: e7c42ed
Author: Gilles <gi...@harfang.homelinux.org>
Authored: Tue May 31 02:28:14 2016 +0200
Committer: Gilles <gi...@harfang.homelinux.org>
Committed: Tue May 31 02:28:14 2016 +0200

----------------------------------------------------------------------
 .../commons/math4/distribution/AbstractIntegerDistribution.java   | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/633de29f/src/main/java/org/apache/commons/math4/distribution/AbstractIntegerDistribution.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/distribution/AbstractIntegerDistribution.java b/src/main/java/org/apache/commons/math4/distribution/AbstractIntegerDistribution.java
index 4612b58..0bc377d 100644
--- a/src/main/java/org/apache/commons/math4/distribution/AbstractIntegerDistribution.java
+++ b/src/main/java/org/apache/commons/math4/distribution/AbstractIntegerDistribution.java
@@ -156,8 +156,7 @@ public abstract class AbstractIntegerDistribution implements IntegerDistribution
      */
     private double checkedCumulativeProbability(int argument)
         throws MathInternalError {
-        double result = Double.NaN;
-        result = cumulativeProbability(argument);
+        final double result = cumulativeProbability(argument);
         if (Double.isNaN(result)) {
             throw new MathInternalError(LocalizedFormats
                     .DISCRETE_CUMULATIVE_PROBABILITY_RETURNED_NAN, argument);


[2/3] [math] Unnecessary String creation.

Posted by er...@apache.org.
Unnecessary String creation.

Thanks to Dave Brosius.


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/362ab2bc
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/362ab2bc
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/362ab2bc

Branch: refs/heads/develop
Commit: 362ab2bc41697980391c4a61c23cb3ef6bce740c
Parents: 633de29
Author: Gilles <gi...@harfang.homelinux.org>
Authored: Tue May 31 02:30:47 2016 +0200
Committer: Gilles <gi...@harfang.homelinux.org>
Committed: Tue May 31 02:30:47 2016 +0200

----------------------------------------------------------------------
 .../math4/stat/descriptive/MultivariateSummaryStatistics.java  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/362ab2bc/src/main/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatistics.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatistics.java b/src/main/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatistics.java
index eb1642c..39083d0 100644
--- a/src/main/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatistics.java
+++ b/src/main/java/org/apache/commons/math4/stat/descriptive/MultivariateSummaryStatistics.java
@@ -319,8 +319,8 @@ public class MultivariateSummaryStatistics
         final String separator = ", ";
         final String suffix = System.getProperty("line.separator");
         StringBuilder outBuffer = new StringBuilder();
-        outBuffer.append("MultivariateSummaryStatistics:" + suffix);
-        outBuffer.append("n: " + getN() + suffix);
+        outBuffer.append("MultivariateSummaryStatistics:").append(suffix);
+        outBuffer.append("n: ").append(getN()).append(suffix);
         append(outBuffer, getMin(), "min: ", separator, suffix);
         append(outBuffer, getMax(), "max: ", separator, suffix);
         append(outBuffer, getMean(), "mean: ", separator, suffix);
@@ -328,7 +328,7 @@ public class MultivariateSummaryStatistics
         append(outBuffer, getSumSq(), "sum of squares: ", separator, suffix);
         append(outBuffer, getSumLog(), "sum of logarithms: ", separator, suffix);
         append(outBuffer, getStandardDeviation(), "standard deviation: ", separator, suffix);
-        outBuffer.append("covariance: " + getCovariance().toString() + suffix);
+        outBuffer.append("covariance: ").append(getCovariance()).append(suffix);
         return outBuffer.toString();
     }
 


[3/3] [math] Perform computation/allocation only if needed.

Posted by er...@apache.org.
Perform computation/allocation only if needed.

Thanks to Dave Brosius.


Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/fc9d93db
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/fc9d93db
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/fc9d93db

Branch: refs/heads/develop
Commit: fc9d93db68a3c33e5ead8c7ecb187fdf0f06cc4f
Parents: 362ab2b
Author: Gilles <gi...@harfang.homelinux.org>
Authored: Tue May 31 02:38:16 2016 +0200
Committer: Gilles <gi...@harfang.homelinux.org>
Committed: Tue May 31 02:38:16 2016 +0200

----------------------------------------------------------------------
 .../math4/stat/interval/ClopperPearsonInterval.java    | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/fc9d93db/src/main/java/org/apache/commons/math4/stat/interval/ClopperPearsonInterval.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/stat/interval/ClopperPearsonInterval.java b/src/main/java/org/apache/commons/math4/stat/interval/ClopperPearsonInterval.java
index bf5d6ad..6f257e7 100644
--- a/src/main/java/org/apache/commons/math4/stat/interval/ClopperPearsonInterval.java
+++ b/src/main/java/org/apache/commons/math4/stat/interval/ClopperPearsonInterval.java
@@ -35,19 +35,18 @@ public class ClopperPearsonInterval implements BinomialConfidenceInterval {
         IntervalUtils.checkParameters(numberOfTrials, numberOfSuccesses, confidenceLevel);
         double lowerBound = 0;
         double upperBound = 0;
-        final double alpha = (1.0 - confidenceLevel) / 2.0;
 
-        final FDistribution distributionLowerBound = new FDistribution(2 * (numberOfTrials - numberOfSuccesses + 1),
-                                                                       2 * numberOfSuccesses);
         if (numberOfSuccesses > 0) {
+	    final double alpha = 0.5 * (1 - confidenceLevel);
+
+	    final FDistribution distributionLowerBound = new FDistribution(2 * (numberOfTrials - numberOfSuccesses + 1),
+									   2 * numberOfSuccesses);
             final double fValueLowerBound = distributionLowerBound.inverseCumulativeProbability(1 - alpha);
             lowerBound = numberOfSuccesses /
                          (numberOfSuccesses + (numberOfTrials - numberOfSuccesses + 1) * fValueLowerBound);
-        }
 
-        final FDistribution distributionUpperBound = new FDistribution(2 * (numberOfSuccesses + 1),
-                                                                       2 * (numberOfTrials - numberOfSuccesses));
-        if (numberOfSuccesses > 0) {
+	    final FDistribution distributionUpperBound = new FDistribution(2 * (numberOfSuccesses + 1),
+									   2 * (numberOfTrials - numberOfSuccesses));
             final double fValueUpperBound = distributionUpperBound.inverseCumulativeProbability(1 - alpha);
             upperBound = (numberOfSuccesses + 1) * fValueUpperBound /
                          (numberOfTrials - numberOfSuccesses + (numberOfSuccesses + 1) * fValueUpperBound);