public abstract class TrapezoidalDistribution extends Object
The probability density function of
for
Note the special cases:
ContinuousDistribution.Sampler
Modifier and Type | Field and Description |
---|---|
protected double |
a
Lower limit of this distribution (inclusive).
|
protected double |
b
Start of the trapezoid constant density.
|
protected double |
c
End of the trapezoid constant density.
|
protected double |
d
Upper limit of this distribution (inclusive).
|
Modifier and Type | Method and Description |
---|---|
ContinuousDistribution.Sampler |
createSampler(UniformRandomProvider rng)
Creates a sampler.
|
double |
getB()
Gets the start of the constant region of the density function.
|
double |
getC()
Gets the end of the constant region of the density function.
|
abstract double |
getMean()
Gets the mean of this distribution.
|
double |
getSupportLowerBound()
Gets the lower bound of the support.
|
double |
getSupportUpperBound()
Gets the upper bound of the support.
|
abstract double |
getVariance()
Gets the variance of this distribution.
|
double |
inverseCumulativeProbability(double p)
Computes the quantile function of this distribution.
|
double |
inverseSurvivalProbability(double p)
Computes the inverse survival probability function of this distribution.
|
static TrapezoidalDistribution |
of(double a,
double b,
double c,
double d)
Creates a trapezoidal distribution.
|
double |
probability(double x0,
double x1)
For a random variable
X whose values are distributed according
to this distribution, this method returns P(x0 < X <= x1) . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
cumulativeProbability, density, logDensity, survivalProbability
protected final double a
protected final double b
protected final double c
protected final double d
public static TrapezoidalDistribution of(double a, double b, double c, double d)
The distribution density is represented as an up sloping line from
a
to b
, constant from b
to c
, and then a down
sloping line from c
to d
.
a
- Lower limit of this distribution (inclusive).b
- Start of the trapezoid constant density (first shape parameter).c
- End of the trapezoid constant density (second shape parameter).d
- Upper limit of this distribution (inclusive).IllegalArgumentException
- if a >= d
, if b < a
, if
c < b
or if c > d
.public abstract double getMean()
For lower limit
public abstract double getVariance()
For lower limit
where
public double getB()
This is the first shape parameter b
of the distribution.
b
public double getC()
This is the second shape parameter c
of the distribution.
c
public double getSupportLowerBound()
inverseCumulativeProbability(0)
, i.e.
The lower bound of the support is equal to the lower limit parameter
a
of the distribution.
public double getSupportUpperBound()
inverseCumulativeProbability(1)
, i.e.
The upper bound of the support is equal to the upper limit parameter
d
of the distribution.
public double probability(double x0, double x1)
X
whose values are distributed according
to this distribution, this method returns P(x0 < X <= x1)
.
The default implementation uses the identity
P(x0 < X <= x1) = P(X <= x1) - P(X <= x0)
probability
in interface ContinuousDistribution
x0
- Lower bound (exclusive).x1
- Upper bound (inclusive).x0
and x1
, excluding the lower
and including the upper endpoint.public double inverseCumulativeProbability(double p)
X
distributed according to this distribution, the
returned value is:
The default implementation returns:
ContinuousDistribution.getSupportLowerBound()
for p = 0
,ContinuousDistribution.getSupportUpperBound()
for p = 1
, orcumulativeProbability(x) - p
.
The bounds may be bracketed for efficiency.inverseCumulativeProbability
in interface ContinuousDistribution
p
- Cumulative probability.p
-quantile of this distribution
(largest 0-quantile for p = 0
).IllegalArgumentException
- if p < 0
or p > 1
public double inverseSurvivalProbability(double p)
X
distributed according to this distribution, the
returned value is:
By default, this is defined as inverseCumulativeProbability(1 - p)
, but
the specific implementation may be more accurate.
The default implementation returns:
ContinuousDistribution.getSupportLowerBound()
for p = 1
,ContinuousDistribution.getSupportUpperBound()
for p = 0
, orsurvivalProbability(x) - p
.
The bounds may be bracketed for efficiency.inverseSurvivalProbability
in interface ContinuousDistribution
p
- Survival probability.(1-p)
-quantile of this distribution
(largest 0-quantile for p = 1
).IllegalArgumentException
- if p < 0
or p > 1
public ContinuousDistribution.Sampler createSampler(UniformRandomProvider rng)
createSampler
in interface ContinuousDistribution
rng
- Generator of uniformly distributed numbers.Copyright © 2018–2022 The Apache Software Foundation. All rights reserved.