commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject [1/6] [math] Added @since tags, cleaned up code. JIRA: MATH-1287
Date Sun, 22 Nov 2015 15:24:35 GMT
Repository: commons-math
Updated Branches:
  refs/heads/field-ode 5bdce0892 -> d75f5090e


Added @since tags, cleaned up code. JIRA: MATH-1287


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

Branch: refs/heads/field-ode
Commit: b38ce47047020643166dc5eb4dd34cdc981fa12f
Parents: 29dfd9b
Author: Phil Steitz <phil.steitz@gmail.com>
Authored: Sun Nov 15 10:56:43 2015 -0700
Committer: Phil Steitz <phil.steitz@gmail.com>
Committed: Sun Nov 15 10:56:43 2015 -0700

----------------------------------------------------------------------
 .../distribution/EnumeratedIntegerDistribution.java      | 11 +++++------
 .../math3/distribution/EnumeratedRealDistribution.java   | 11 +++++------
 2 files changed, 10 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-math/blob/b38ce470/src/main/java/org/apache/commons/math3/distribution/EnumeratedIntegerDistribution.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/distribution/EnumeratedIntegerDistribution.java
b/src/main/java/org/apache/commons/math3/distribution/EnumeratedIntegerDistribution.java
index 9e29b66..399baad 100644
--- a/src/main/java/org/apache/commons/math3/distribution/EnumeratedIntegerDistribution.java
+++ b/src/main/java/org/apache/commons/math3/distribution/EnumeratedIntegerDistribution.java
@@ -107,19 +107,17 @@ public class EnumeratedIntegerDistribution extends AbstractIntegerDistribution
{
      *
      * @param rng random number generator used for sampling
      * @param data input dataset
+     * @since 3.6
      */
     public EnumeratedIntegerDistribution(final RandomGenerator rng, final int[] data) {
         super(rng);
         final Map<Integer, Integer> dataMap = new HashMap<Integer, Integer>();
-
         for (int value : data) {
             Integer count = dataMap.get(value);
             if (count == null) {
-                count = new Integer(1);
-            } else {
-                count = new Integer(count.intValue() + 1);
+                count = 0;
             }
-            dataMap.put(value, count);
+            dataMap.put(value, ++count);
         }
         final int massPoints = dataMap.size();
         final double denom = data.length;
@@ -140,6 +138,7 @@ public class EnumeratedIntegerDistribution extends AbstractIntegerDistribution
{
      * with values 0, 1 and 2 having probability masses 0.25, 0.5 and 0.25 respectively,
      *
      * @param data input dataset
+     * @since 3.6
      */
     public EnumeratedIntegerDistribution(final int[] data) {
         this(new Well19937c(), data);
@@ -152,7 +151,7 @@ public class EnumeratedIntegerDistribution extends AbstractIntegerDistribution
{
      * @param probabilities probabilities
      * @return list of value/probability pairs
      */
-    private  List<Pair<Integer, Double>>  createDistribution(int[] singletons,
double[] probabilities) {
+    private static List<Pair<Integer, Double>>  createDistribution(int[] singletons,
double[] probabilities) {
         if (singletons.length != probabilities.length) {
             throw new DimensionMismatchException(probabilities.length, singletons.length);
         }

http://git-wip-us.apache.org/repos/asf/commons-math/blob/b38ce470/src/main/java/org/apache/commons/math3/distribution/EnumeratedRealDistribution.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/distribution/EnumeratedRealDistribution.java
b/src/main/java/org/apache/commons/math3/distribution/EnumeratedRealDistribution.java
index 2edb375..7e95e8e 100644
--- a/src/main/java/org/apache/commons/math3/distribution/EnumeratedRealDistribution.java
+++ b/src/main/java/org/apache/commons/math3/distribution/EnumeratedRealDistribution.java
@@ -109,19 +109,17 @@ public class EnumeratedRealDistribution extends AbstractRealDistribution
{
      *
      * @param rng random number generator used for sampling
      * @param data input dataset
+     * @since 3.6
      */
     public EnumeratedRealDistribution(final RandomGenerator rng, final double[] data) {
         super(rng);
         final Map<Double, Integer> dataMap = new HashMap<Double, Integer>();
-
         for (double value : data) {
             Integer count = dataMap.get(value);
             if (count == null) {
-                count = new Integer(1);
-            } else {
-                count = new Integer(count.intValue() + 1);
+                count = 0;
             }
-            dataMap.put(value, count);
+            dataMap.put(value, ++count);
         }
         final int massPoints = dataMap.size();
         final double denom = data.length;
@@ -142,6 +140,7 @@ public class EnumeratedRealDistribution extends AbstractRealDistribution
{
      * with values 0, 1 and 2 having probability masses 0.25, 0.5 and 0.25 respectively,
      *
      * @param data input dataset
+     * @since 3.6
      */
     public EnumeratedRealDistribution(final double[] data) {
         this(new Well19937c(), data);
@@ -153,7 +152,7 @@ public class EnumeratedRealDistribution extends AbstractRealDistribution
{
      * @param probabilities probabilities
      * @return list of value/probability pairs
      */
-    private  List<Pair<Double, Double>>  createDistribution(double[] singletons,
double[] probabilities) {
+    private static List<Pair<Double, Double>>  createDistribution(double[] singletons,
double[] probabilities) {
         if (singletons.length != probabilities.length) {
             throw new DimensionMismatchException(probabilities.length, singletons.length);
         }


Mime
View raw message