Interface Sampler

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Sampler
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 Details

  • Method Details

    • sample

      double sample(RandomGenerator random, DoubleRange range)
      Create a new double sample point within the given range [min, max).
      Parameters:
      random - the random generator used for creating a sample point of the defined distribution
      range - the range of the sample point: [min, max)
      Returns:
      a new sample point between [min, max)
    • sample

      default int sample(RandomGenerator random, IntRange range)
      Create a new int sample point within the given range [min, max).
      Parameters:
      random - the random generator used for creating a sample point of the defined distribution
      range - the range of the sample point: [min, max)
      Returns:
      a new sample point between [min, max)