You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Phil Steitz <ph...@steitz.com> on 2012/12/15 00:43:41 UTC

Re: svn commit: r1422123 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/EmpiricalDistribution.java

Looks good.  Thanks!

Phil

On 12/14/12 2:12 PM, erans@apache.org wrote:
> Author: erans
> Date: Fri Dec 14 22:12:34 2012
> New Revision: 1422123
>
> URL: http://svn.apache.org/viewvc?rev=1422123&view=rev
> Log:
> Replaced deprecated "RandomDataImpl" with "RandomDataGenerator".
> Added private constructor.
>
> Modified:
>     commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/EmpiricalDistribution.java
>
> Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/EmpiricalDistribution.java
> URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/EmpiricalDistribution.java?rev=1422123&r1=1422122&r2=1422123&view=diff
> ==============================================================================
> --- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/EmpiricalDistribution.java (original)
> +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/EmpiricalDistribution.java Fri Dec 14 22:12:34 2012
> @@ -134,14 +134,14 @@ public class EmpiricalDistribution exten
>      /** upper bounds of subintervals in (0,1) "belonging" to the bins */
>      private double[] upperBounds = null;
>  
> -    /** RandomDataImpl instance to use in repeated calls to getNext() */
> -    private final RandomDataImpl randomData;
> +    /** RandomDataGenerator instance to use in repeated calls to getNext() */
> +    private final RandomDataGenerator randomData;
>  
>      /**
>       * Creates a new EmpiricalDistribution with the default bin count.
>       */
>      public EmpiricalDistribution() {
> -        this(DEFAULT_BIN_COUNT, new RandomDataImpl());
> +        this(DEFAULT_BIN_COUNT);
>      }
>  
>      /**
> @@ -150,7 +150,7 @@ public class EmpiricalDistribution exten
>       * @param binCount number of bins
>       */
>      public EmpiricalDistribution(int binCount) {
> -        this(binCount, new RandomDataImpl());
> +        this(binCount, new RandomDataGenerator());
>      }
>  
>      /**
> @@ -162,9 +162,7 @@ public class EmpiricalDistribution exten
>       * @since 3.0
>       */
>      public EmpiricalDistribution(int binCount, RandomGenerator generator) {
> -        this.binCount = binCount;
> -        randomData = new RandomDataImpl(generator);
> -        binStats = new ArrayList<SummaryStatistics>();
> +        this(binCount, new RandomDataGenerator(generator));
>      }
>  
>      /**
> @@ -189,9 +187,7 @@ public class EmpiricalDistribution exten
>       */
>      @Deprecated
>      public EmpiricalDistribution(int binCount, RandomDataImpl randomData) {
> -        this.binCount = binCount;
> -        this.randomData = randomData;
> -        binStats = new ArrayList<SummaryStatistics>();
> +        this(binCount, randomData.getDelegate());
>      }
>  
>      /**
> @@ -207,7 +203,22 @@ public class EmpiricalDistribution exten
>          this(DEFAULT_BIN_COUNT, randomData);
>      }
>  
> -     /**
> +    /**
> +     * Private constructor to allow lazy initialisation of the RNG contained
> +     * in the {@link #randomData} instance variable.
> +     *
> +     * @param binCount number of bins
> +     * @param randomData Random data generator.
> +     */
> +    private EmpiricalDistribution(int binCount,
> +                                  RandomDataGenerator randomData) {
> +        super(null);
> +        this.binCount = binCount;
> +        this.randomData = randomData;
> +        binStats = new ArrayList<SummaryStatistics>();
> +    }
> +
> +    /**
>       * Computes the empirical distribution from the provided
>       * array of numbers.
>       *
>
>
>


-- 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org