commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbros...@apache.org
Subject [math] push down allocations/calculations to where they are needed
Date Tue, 29 Dec 2015 18:53:02 GMT
Repository: commons-math
Updated Branches:
  refs/heads/master d1123894d -> fb83ba3fd


push down allocations/calculations to where they are needed


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

Branch: refs/heads/master
Commit: fb83ba3fdb46537a36832a900f124d4c400f7ed9
Parents: d112389
Author: Dave Brosius <dbrosius@mebigfatguy.com>
Authored: Tue Dec 29 13:52:48 2015 -0500
Committer: Dave Brosius <dbrosius@mebigfatguy.com>
Committed: Tue Dec 29 13:52:48 2015 -0500

----------------------------------------------------------------------
 .../optim/nonlinear/scalar/noderiv/CMAESOptimizer.java    | 10 ++++++----
 .../math4/stat/interval/ClopperPearsonInterval.java       |  4 ++--
 2 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/fb83ba3f/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java
b/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java
index f769585..727fd18 100644
--- a/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java
+++ b/src/main/java/org/apache/commons/math4/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java
@@ -556,14 +556,16 @@ public class CMAESOptimizer
      * Checks dimensions and values of boundaries and inputSigma if defined.
      */
     private void checkParameters() {
-        final double[] init = getStartPoint();
-        final double[] lB = getLowerBound();
-        final double[] uB = getUpperBound();
-
         if (inputSigma != null) {
+            final double[] init = getStartPoint();
+
             if (inputSigma.length != init.length) {
                 throw new DimensionMismatchException(inputSigma.length, init.length);
             }
+
+            final double[] lB = getLowerBound();
+            final double[] uB = getUpperBound();
+
             for (int i = 0; i < init.length; i++) {
                 if (inputSigma[i] > uB[i] - lB[i]) {
                     throw new OutOfRangeException(inputSigma[i], 0, uB[i] - lB[i]);

http://git-wip-us.apache.org/repos/asf/commons-math/blob/fb83ba3f/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 17dc9f5..bf5d6ad 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
@@ -39,16 +39,16 @@ public class ClopperPearsonInterval implements BinomialConfidenceInterval
{
 
         final FDistribution distributionLowerBound = new FDistribution(2 * (numberOfTrials
- numberOfSuccesses + 1),
                                                                        2 * numberOfSuccesses);
-        final double fValueLowerBound = distributionLowerBound.inverseCumulativeProbability(1
- alpha);
         if (numberOfSuccesses > 0) {
+            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));
-        final double fValueUpperBound = distributionUpperBound.inverseCumulativeProbability(1
- alpha);
         if (numberOfSuccesses > 0) {
+            final double fValueUpperBound = distributionUpperBound.inverseCumulativeProbability(1
- alpha);
             upperBound = (numberOfSuccesses + 1) * fValueUpperBound /
                          (numberOfTrials - numberOfSuccesses + (numberOfSuccesses + 1) *
fValueUpperBound);
         }


Mime
View raw message