Package org.apache.commons.rng.sampling
Class CompositeSamplers.SamplerBuilder.WeightedSampler<S>
java.lang.Object
org.apache.commons.rng.sampling.CompositeSamplers.SamplerBuilder.WeightedSampler<S>
- Type Parameters:
S
- Sampler type
- Enclosing class:
CompositeSamplers.SamplerBuilder<S>
Contains a weighted sampler.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) S
Gets the sampler.(package private) double
Gets the weight.private static double
requirePositiveFinite
(double value, String message) Checks that the specified value is positive finite and throws a customizedIllegalArgumentException
if it is not.
-
Field Details
-
weight
private final double weightThe weight. -
sampler
The sampler.
-
-
Constructor Details
-
WeightedSampler
WeightedSampler(double weight, S sampler) - Parameters:
weight
- the weightsampler
- the sampler- Throws:
IllegalArgumentException
- ifweight
is negative, infinite orNaN
.NullPointerException
- ifsampler
is null.
-
-
Method Details
-
getWeight
double getWeight()Gets the weight.- Returns:
- the weight
-
getSampler
S getSampler()Gets the sampler.- Returns:
- the sampler
-
requirePositiveFinite
Checks that the specified value is positive finite and throws a customizedIllegalArgumentException
if it is not.- Parameters:
value
- the valuemessage
- detail message to be used in the event that aIllegalArgumentException
is thrown- Returns:
value
if positive finite- Throws:
IllegalArgumentException
- ifweight
is negative, infinite orNaN
.
-