public class TruncatedWrapper extends RejectionWrapper
RejectionWrapper.constraint
and rescales the rest of the distribution to become a valid one again.
This class should be used if samples from the original distribution are unlikely to fall into the region above the RejectionWrapper.constraint
.
The sampling of random values from this distribution is done by the slice sampling technique.
for the simpler version building on rejection sampling.
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected SliceSampler |
sampler
sampler to sample from constrained distribution directly
|
constraint, scale, wrappedDist
cachedMean, cachedVariance
Modifier and Type | Method and Description |
---|---|
void |
reseedRandomGenerator(long seed) |
double |
sample()
Slice sampling
Note that due to floating point arithmetic, too large constraints, i.e.
|
double[] |
sample(int sampleSize) |
density, getSupportLowerBound, getSupportUpperBound, isSupportConnected, isSupportLowerBoundInclusive, isSupportUpperBoundInclusive
cumulativeProbability, getNumericalMean, getNumericalVariance, value
protected SliceSampler sampler
public void reseedRandomGenerator(long seed)
reseedRandomGenerator
in interface org.apache.commons.math3.distribution.RealDistribution
reseedRandomGenerator
in class RejectionWrapper
public double sample()
sample
in interface org.apache.commons.math3.distribution.RealDistribution
sample
in class RejectionWrapper
java.lang.IllegalArgumentException
- when constraint is too high, i.e., density is (floating point rounded) zero.public double[] sample(int sampleSize)
sample
in interface org.apache.commons.math3.distribution.RealDistribution
sample
in class RejectionWrapper