This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-statistics.git

commit d313b3cda4d182e71a2ca475e9546fed7755eec7
Author: aherbert <aherb...@apache.org>
AuthorDate: Fri Jul 30 12:06:32 2021 +0100

    Reorder methods to match DiscreteDistribution
    
    Move getters to first methods after the constructor.
---
 .../distribution/HypergeometricDistribution.java   | 90 +++++++++++-----------
 1 file changed, 45 insertions(+), 45 deletions(-)

diff --git 
a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/HypergeometricDistribution.java
 
b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/HypergeometricDistribution.java
index 4b3e16c..3373d73 100644
--- 
a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/HypergeometricDistribution.java
+++ 
b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/HypergeometricDistribution.java
@@ -74,38 +74,6 @@ public class HypergeometricDistribution extends 
AbstractDiscreteDistribution {
         upperBound = getUpperDomain(numberOfSuccesses, sampleSize);
     }
 
-    /** {@inheritDoc} */
-    @Override
-    public double cumulativeProbability(int x) {
-        double ret;
-
-        if (x < lowerBound) {
-            ret = 0.0;
-        } else if (x >= upperBound) {
-            ret = 1.0;
-        } else {
-            ret = innerCumulativeProbability(lowerBound, x);
-        }
-
-        return ret;
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public double survivalProbability(int x) {
-        double ret;
-
-        if (x < lowerBound) {
-            ret = 1.0;
-        } else if (x >= upperBound) {
-            ret = 0.0;
-        } else {
-            ret = innerCumulativeProbability(upperBound, x + 1);
-        }
-
-        return ret;
-    }
-
     /**
      * Return the lowest domain value for the given hypergeometric distribution
      * parameters.
@@ -120,6 +88,18 @@ public class HypergeometricDistribution extends 
AbstractDiscreteDistribution {
     }
 
     /**
+     * Return the highest domain value for the given hypergeometric 
distribution
+     * parameters.
+     *
+     * @param m Number of successes in the population.
+     * @param k Sample size.
+     * @return the highest domain value of the hypergeometric distribution.
+     */
+    private static int getUpperDomain(int m, int k) {
+        return Math.min(k, m);
+    }
+
+    /**
      * Access the number of successes.
      *
      * @return the number of successes.
@@ -146,18 +126,6 @@ public class HypergeometricDistribution extends 
AbstractDiscreteDistribution {
         return sampleSize;
     }
 
-    /**
-     * Return the highest domain value for the given hypergeometric 
distribution
-     * parameters.
-     *
-     * @param m Number of successes in the population.
-     * @param k Sample size.
-     * @return the highest domain value of the hypergeometric distribution.
-     */
-    private static int getUpperDomain(int m, int k) {
-        return Math.min(k, m);
-    }
-
     /** {@inheritDoc} */
     @Override
     public double probability(int x) {
@@ -200,10 +168,42 @@ public class HypergeometricDistribution extends 
AbstractDiscreteDistribution {
         return p1 + p2 - p3;
     }
 
+    /** {@inheritDoc} */
+    @Override
+    public double cumulativeProbability(int x) {
+        double ret;
+
+        if (x < lowerBound) {
+            ret = 0.0;
+        } else if (x >= upperBound) {
+            ret = 1.0;
+        } else {
+            ret = innerCumulativeProbability(lowerBound, x);
+        }
+
+        return ret;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public double survivalProbability(int x) {
+        double ret;
+
+        if (x < lowerBound) {
+            ret = 1.0;
+        } else if (x >= upperBound) {
+            ret = 0.0;
+        } else {
+            ret = innerCumulativeProbability(upperBound, x + 1);
+        }
+
+        return ret;
+    }
+
     /**
      * For this distribution, {@code X}, this method returns {@code P(X >= x)}.
      *
-     * <p>Note: This is not equals to {@link #survivalProbability(int)} which 
computes {@code P(X > x)}.
+     * <p>Note: This is not equal to {@link #survivalProbability(int)} which 
computes {@code P(X > x)}.
      *
      * @param x Value at which the CDF is evaluated.
      * @return the upper tail CDF for this distribution.

Reply via email to