Use method reference for the sampler
This commit is contained in:
parent
9fcd3885dc
commit
abb32b5a62
|
@ -218,16 +218,6 @@ public class EnumeratedIntegerDistribution extends AbstractIntegerDistribution {
|
|||
*/
|
||||
@Override
|
||||
public DiscreteDistribution.Sampler createSampler(final UniformRandomProvider rng) {
|
||||
return new DiscreteDistribution.Sampler() {
|
||||
/** Delegate. */
|
||||
private final EnumeratedDistribution<Integer>.Sampler inner =
|
||||
innerDistribution.createSampler(rng);
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public int sample() {
|
||||
return inner.sample();
|
||||
}
|
||||
};
|
||||
return innerDistribution.createSampler(rng)::sample;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -249,16 +249,6 @@ public class EnumeratedRealDistribution
|
|||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public ContinuousDistribution.Sampler createSampler(final UniformRandomProvider rng) {
|
||||
return new ContinuousDistribution.Sampler() {
|
||||
/** Delegate. */
|
||||
private final EnumeratedDistribution<Double>.Sampler inner =
|
||||
innerDistribution.createSampler(rng);
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public double sample() {
|
||||
return inner.sample();
|
||||
}
|
||||
};
|
||||
return innerDistribution.createSampler(rng)::sample;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue