Class UniformDouble
java.lang.Object
org.loudouncodes.randkit.continuous.UniformDouble
- All Implemented Interfaces:
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
ConstructorsConstructorDescriptionUniformDouble(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 TypeMethodDescriptiondoublecdf(double x) Cumulative distribution function (CDF).doubleThe inclusive lower bounda.doublemean()Theoretical mean of the distribution, when defined.doublepdf(double x) Probability density function (PDF).doublequantile(double p) Quantile function (inverse CDF).doublesample()Draw a single sample from the distribution.support()Returns the mathematical support of this distribution: the half-open interval [a, b).doubleThe exclusive upper boundb.doublevariance()Theoretical variance of the distribution, when defined.
-
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 boundb- exclusive upper bound; must satisfya < b- Throws:
IllegalArgumentException- ifa >= bor 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 reproducibilitya- inclusive lower boundb- exclusive upper bound; must satisfya < b- Throws:
IllegalArgumentException- ifa >= bor any bound is not finite
-
UniformDouble
Constructs a UniformDouble(a, b) using the provided generator.- Parameters:
rng- non-null random generator supplying independent U(0,1) variatesa- inclusive lower boundb- exclusive upper bound; must satisfya < b- Throws:
NullPointerException- ifrngis nullIllegalArgumentException- ifa >= bor any bound is not finite
-
-
Method Details
-
sample
public double sample()Draw a single sample from the distribution.- Specified by:
samplein interfaceContinuousDistribution- Returns:
- a random variate
-
pdf
public double pdf(double x) Probability density function (PDF).- Specified by:
pdfin interfaceContinuousDistribution- 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:
cdfin interfaceContinuousDistribution- 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
pin the open interval (0, 1), returns a valueqsuch thatcdf(q) ≈ p. Forp == 0orp == 1, implementations may returnDouble.NEGATIVE_INFINITYorDouble.POSITIVE_INFINITY, respectively, where appropriate.- Specified by:
quantilein interfaceContinuousDistribution- 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:
meanin interfaceContinuousDistribution- Returns:
- the mean; may be
Double.NaNif undefined
-
variance
public double variance()Theoretical variance of the distribution, when defined.- Specified by:
variancein interfaceContinuousDistribution- Returns:
- the variance; may be
Double.NaNif undefined or infinite
-
support
Returns the mathematical support of this distribution: the half-open interval [a, b).- Returns:
- a
DistributionSupportdescribing[a, b)
-
lowerBound
public double lowerBound()The inclusive lower bounda.- Returns:
- the lower bound value
a
-
upperBound
public double upperBound()The exclusive upper boundb.- Returns:
- the upper bound value
b
-