Class UniformDouble

java.lang.Object
org.loudouncodes.randkit.continuous.UniformDouble
All Implemented Interfaces:
ContinuousDistribution

public final class UniformDouble extends Object implements ContinuousDistribution
Continuous Uniform(a, b) on the half-open interval [a, b) with a < b.

PDF: f(x) = 1 / (b - a) for x ∈ [a, b), else 0.
CDF: F(x) = 0 for x ≤ a; (x - a)/(b - a) for a < x < b; and 1 for x ≥ b.

  • Constructor Summary

    Constructors
    Constructor
    Description
    UniformDouble(double a, double b)
    Constructs a UniformDouble(a, b) using a platform-provided, high-quality default RNG.
    UniformDouble(long seed, double a, double b)
    Constructs a UniformDouble(a, b) with a deterministic seed.
    UniformDouble(RandomGenerator rng, double a, double b)
    Constructs a UniformDouble(a, b) using the provided generator.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    cdf(double x)
    Cumulative distribution function (CDF).
    double
    The inclusive lower bound a.
    double
    Theoretical mean of the distribution, when defined.
    double
    pdf(double x)
    Probability density function (PDF).
    double
    quantile(double p)
    Quantile function (inverse CDF).
    double
    Draw a single sample from the distribution.
    Returns the mathematical support of this distribution: the half-open interval [a, b).
    double
    The exclusive upper bound b.
    double
    Theoretical variance of the distribution, when defined.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • UniformDouble

      public UniformDouble(double a, double b)
      Constructs a UniformDouble(a, b) using a platform-provided, high-quality default RNG.
      Parameters:
      a - inclusive lower bound
      b - exclusive upper bound; must satisfy a < b
      Throws:
      IllegalArgumentException - if a >= b or any bound is not finite
    • UniformDouble

      public UniformDouble(long seed, double a, double b)
      Constructs a UniformDouble(a, b) with a deterministic seed.
      Parameters:
      seed - random seed for reproducibility
      a - inclusive lower bound
      b - exclusive upper bound; must satisfy a < b
      Throws:
      IllegalArgumentException - if a >= b or any bound is not finite
    • UniformDouble

      public UniformDouble(RandomGenerator rng, double a, double b)
      Constructs a UniformDouble(a, b) using the provided generator.
      Parameters:
      rng - non-null random generator supplying independent U(0,1) variates
      a - inclusive lower bound
      b - exclusive upper bound; must satisfy a < b
      Throws:
      NullPointerException - if rng is null
      IllegalArgumentException - if a >= b or any bound is not finite
  • Method Details

    • sample

      public double sample()
      Draw a single sample from the distribution.
      Specified by:
      sample in interface ContinuousDistribution
      Returns:
      a random variate
    • pdf

      public double pdf(double x)
      Probability density function (PDF).
      Specified by:
      pdf in interface ContinuousDistribution
      Parameters:
      x - point at which to evaluate the density
      Returns:
      the density value f(x); 0.0 for points outside the support
    • cdf

      public double cdf(double x)
      Cumulative distribution function (CDF).
      Specified by:
      cdf in interface ContinuousDistribution
      Parameters:
      x - point at which to evaluate the cumulative probability
      Returns:
      F(x) = P(X ≤ x), in the closed interval [0, 1]
    • quantile

      public double quantile(double p)
      Quantile function (inverse CDF).

      For p in the open interval (0, 1), returns a value q such that cdf(q) ≈ p. For p == 0 or p == 1, implementations may return Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY, respectively, where appropriate.

      Specified by:
      quantile in interface ContinuousDistribution
      Parameters:
      p - cumulative probability, typically in [0, 1]
      Returns:
      a quantile corresponding to p
    • mean

      public double mean()
      Theoretical mean of the distribution, when defined.
      Specified by:
      mean in interface ContinuousDistribution
      Returns:
      the mean; may be Double.NaN if undefined
    • variance

      public double variance()
      Theoretical variance of the distribution, when defined.
      Specified by:
      variance in interface ContinuousDistribution
      Returns:
      the variance; may be Double.NaN if undefined or infinite
    • support

      public DistributionSupport support()
      Returns the mathematical support of this distribution: the half-open interval [a, b).
      Returns:
      a DistributionSupport describing [a, b)
    • lowerBound

      public double lowerBound()
      The inclusive lower bound a.
      Returns:
      the lower bound value a
    • upperBound

      public double upperBound()
      The exclusive upper bound b.
      Returns:
      the upper bound value b