- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Interface for creating continuous random samples, with a given
distribution. This interface isn't responsible for creating the
random numbers itself. It uses a
RandomGenerator generator, which is
given by the caller.
final var random = RandomGenerator.getDefault();
final var range = DoubleRange.of(0, 1);
final var sampler = Sampler.linear(0.1);
// Create a new sample point, which obeys the given distribution.
// The random generator is responsible for the base randomness.
final double value = sampler.sample(random, range);
- Since:
- 8.0
- Version:
- 8.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SamplerDefault uniform distribution by callingRandomGenerator.nextDouble(double, double). -
Method Summary
Modifier and TypeMethodDescriptiondoublesample(RandomGenerator random, DoubleRange range) Create a newdoublesample point within the given range[min, max).default intsample(RandomGenerator random, IntRange range) Create a newintsample point within the given range[min, max).
-
Field Details
-
UNIFORM
Default uniform distribution by callingRandomGenerator.nextDouble(double, double).
-
-
Method Details
-
sample
Create a newdoublesample point within the given range[min, max).- Parameters:
random- the random generator used for creating a sample point of the defined distributionrange- the range of the sample point:[min, max)- Returns:
- a new sample point between
[min, max)
-
sample
Create a newintsample point within the given range[min, max).- Parameters:
random- the random generator used for creating a sample point of the defined distributionrange- the range of the sample point:[min, max)- Returns:
- a new sample point between
[min, max)
-