Replaced deprecated "RandomDataImpl" with "RandomDataGenerator".

Added private constructor.


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1422123 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gilles Sadowski 2012-12-14 22:12:34 +00:00
parent 1f7c434521
commit f235e1c1d0
1 changed files with 22 additions and 11 deletions

View File

@ -134,14 +134,14 @@ public class EmpiricalDistribution extends AbstractRealDistribution {
/** upper bounds of subintervals in (0,1) "belonging" to the bins */ /** upper bounds of subintervals in (0,1) "belonging" to the bins */
private double[] upperBounds = null; private double[] upperBounds = null;
/** RandomDataImpl instance to use in repeated calls to getNext() */ /** RandomDataGenerator instance to use in repeated calls to getNext() */
private final RandomDataImpl randomData; private final RandomDataGenerator randomData;
/** /**
* Creates a new EmpiricalDistribution with the default bin count. * Creates a new EmpiricalDistribution with the default bin count.
*/ */
public EmpiricalDistribution() { public EmpiricalDistribution() {
this(DEFAULT_BIN_COUNT, new RandomDataImpl()); this(DEFAULT_BIN_COUNT);
} }
/** /**
@ -150,7 +150,7 @@ public class EmpiricalDistribution extends AbstractRealDistribution {
* @param binCount number of bins * @param binCount number of bins
*/ */
public EmpiricalDistribution(int binCount) { public EmpiricalDistribution(int binCount) {
this(binCount, new RandomDataImpl()); this(binCount, new RandomDataGenerator());
} }
/** /**
@ -162,9 +162,7 @@ public class EmpiricalDistribution extends AbstractRealDistribution {
* @since 3.0 * @since 3.0
*/ */
public EmpiricalDistribution(int binCount, RandomGenerator generator) { public EmpiricalDistribution(int binCount, RandomGenerator generator) {
this.binCount = binCount; this(binCount, new RandomDataGenerator(generator));
randomData = new RandomDataImpl(generator);
binStats = new ArrayList<SummaryStatistics>();
} }
/** /**
@ -189,9 +187,7 @@ public class EmpiricalDistribution extends AbstractRealDistribution {
*/ */
@Deprecated @Deprecated
public EmpiricalDistribution(int binCount, RandomDataImpl randomData) { public EmpiricalDistribution(int binCount, RandomDataImpl randomData) {
this.binCount = binCount; this(binCount, randomData.getDelegate());
this.randomData = randomData;
binStats = new ArrayList<SummaryStatistics>();
} }
/** /**
@ -207,7 +203,22 @@ public class EmpiricalDistribution extends AbstractRealDistribution {
this(DEFAULT_BIN_COUNT, randomData); 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 * Computes the empirical distribution from the provided
* array of numbers. * array of numbers.
* *