- 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
Modifier and TypeFieldDescriptionstatic final Sampler
Default uniform distribution by callingRandomGenerator.nextDouble(double, double)
. -
Method Summary
Modifier and TypeMethodDescriptiondouble
sample
(RandomGenerator random, DoubleRange range) Create a newdouble
sample point within the given range[min, max)
.default int
sample
(RandomGenerator random, IntRange range) Create a newint
sample point within the given range[min, max)
.
-
Field Details
-
UNIFORM
Default uniform distribution by callingRandomGenerator.nextDouble(double, double)
.
-
-
Method Details
-
sample
Create a newdouble
sample 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 newint
sample 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)
-