public final class InvCdf extends Object
Modifier and Type | Method and Description |
---|---|
static double |
beta(double p,
double pin,
double qin)
Returns the inverse of the beta cumulative probability distribution function.
|
static double |
chi(double p,
double df)
Returns the inverse of the chi-squared cumulative probability distribution function.
|
static double |
continuousUniform(double p,
double a,
double b)
Returns the inverse of the continuous uniform cumulative distribution function.
|
static int |
discreteUniform(double p,
int n)
Returns the inverse of the discrete uniform cumulative probability distribution function.
|
static double |
exponential(double p,
double scale)
Returns the inverse of the exponential cumulative probability distribution function.
|
static double |
extremeValue(double p,
double mu,
double beta)
Returns the inverse of the extreme value cumulative probability distribution function.
|
static double |
F(double p,
double dfn,
double dfd)
Returns the inverse of the F cumulative probability distribution function.
|
static double |
gamma(double p,
double a)
Returns the inverse of the gamma cumulative probability distribution function.
|
static double |
generalizedExtremeValue(double p,
double mu,
double sigma,
double xi)
Returns the inverse of the generalized extreme value cumulative distribution function.
|
static double |
generalizedGaussian(double p,
double mu,
double alpha,
double beta)
Returns the inverse of the generalized Gaussian (normal) cumulative
distribution function.
|
static double |
generalizedPareto(double p,
double mu,
double sigma,
double alpha)
Returns the inverse of the generalized Pareto cumulative distribution function.
|
static double |
geometric(double r,
double pin)
Returns the inverse of the discrete geometric cumulative probability distribution function.
|
static double |
logistic(double p,
double mu,
double sigma)
Returns the inverse of the logistic cumulative probability distribution
function.
|
static double |
logNormal(double p,
double mu,
double sigma)
Returns the inverse of the standard lognormal cumulative probability
distribution function.
|
static double |
noncentralBeta(double p,
double shape1,
double shape2,
double lambda)
Returns the inverse of the noncentral beta cumulative distribution function (CDF).
|
static double |
noncentralchi(double p,
double df,
double alam)
Returns the inverse of the noncentral chi-squared cumulative probability distribution function.
|
static double |
noncentralF(double p,
double dfn,
double dfd,
double lambda)
Returns the inverse of the noncentral F cumulative distribution
function (CDF).
|
static double |
noncentralstudentsT(double p,
int idf,
double delta)
Returns the inverse of the noncentral Student's t cumulative probability distribution function.
|
static double |
normal(double p)
Returns the inverse of the normal (Gaussian) cumulative probability distribution function.
|
static double |
Pareto(double p,
double xm,
double k)
Returns the inverse of the Pareto cumulative probability density function.
|
static double |
Rayleigh(double p,
double alpha)
Returns the inverse of the Rayleigh cumulative probability distribution
function.
|
static double |
studentsT(double p,
double df)
Returns the inverse of the Student's t cumulative probability distribution function.
|
static double |
uniform(double p,
double aa,
double bb)
Deprecated.
use
InvCdf.continuousUniform(double, double, double) instead |
static double |
Weibull(double p,
double gamma,
double alpha)
Returns the inverse of the Weibull cumulative probability distribution function.
|
public static double beta(double p, double pin, double qin)
Method beta
evaluates the inverse distribution
function of a beta random variable with parameters pin
and
qin
, that is, with P = p,
p = pin, and q = qin, it
determines x (equal to
beta (p, pin, qin)
), such that
$$P = \frac{{\Gamma \left( p \right)\Gamma \left( q \right)}}{{\Gamma \left( {p + q} \right)}}\int_0^x {t^{p - 1} } \left( {1 - t} \right)^{q - 1} dt$$
where \(\Gamma(\cdot)\) is the gamma function. The probability that the random variable takes a value less than or equal to x is P.
p
- a double
, the probability for which the inverse of the
beta CDF is to be evaluated.pin
- a double
, the first beta distribution parameter.qin
- a double
, the second beta distribution parameter.double
, the p
th quantile x
given the parameter values.public static double F(double p, double dfn, double dfd)
Method F
evaluates the inverse distribution
function of a Snedecor's F random variable with
dfn
numerator degrees of freedom and dfd
denominator degrees of freedom. The function is evaluated by making a
transformation to a beta random variable and then using
beta
. If X is an
F variate with \(v_1\) and
\(v_2\) degrees of freedom and
\(Y = v_1X/(v_2 + v_1X)\), then Y
is a beta variate with parameters \(p = v_1/2\) and
\(q = v_2/2\). If \(P \le 0.5\),
F
uses this relationship directly, otherwise, it
also uses a relationship between X random variables
that can be expressed as follows, using f
, which is the
F cumulative distribution function:
$${\rm F}(X, {\it dfn}, {\it dfd})=1 - {\rm F}(1/X, {\it dfd}, {\it dfn})$$
p
- a double
, the probability for which the
inverse of the F distribution function is to
be evaluated. Argument p must be in the open
interval (0.0, 1.0).dfn
- a double
, the numerator degrees of
freedom. It must be positive.dfd
- a double
, the denominator degrees of
freedom. It must be positive.double
, the p
th quantile x
given the parameter values.public static double gamma(double p, double a)
Method gamma
evaluates the inverse distribution
function of a gamma random variable with shape parameter
a. That is, it determines
\(x \) such that
$$p = \frac{1}{{\Gamma \left( a \right)}}\int_o^x {e^{ - t} } t^{a - 1} dt$$
where \(\Gamma(\cdot)\) is the gamma function. The
probability that the random variable takes a value less than or equal to
x is p. See the documentation
for routine gamma
for further discussion of the gamma
distribution.
gamma
uses bisection and modified regula falsi
to invert the distribution function, which is evaluated using method
gamma
.
p
- a double
, the probability at which the
function is to be evaluateda
- a double
, the value of the
shape parameter. This must be positive.double
, the p
th quantile x
given the parameter valuespublic static double generalizedExtremeValue(double p, double mu, double sigma, double xi)
Returns the quantile \(x\) such that \(p = F(x|\mu,\sigma,\xi) \) where \(p\) is a probability and $$F(x|\mu,\sigma,\xi)=e^{-t(x)}$$ where $$t(x)=\left\{\begin{array}{lll} (1+\xi(\frac{x-\mu}{\sigma}))^{-\frac{1}{\xi}}& \mbox{for} & \xi \ne 0 \\ e^{-\frac{x-\mu}{\sigma}} & \mbox{for} & \xi = 0 \end{array}\right. $$ \( \mu\in \mathbb{R} \) is the location parameter, \(\sigma > 0 \) is the scale parameter, and \(\xi \in \mathbb{R} \) is the shape parameter. Furthermore, the support for the distribution is $$\left\{\begin{array}{lll} x \in \mathbb{R} & \mbox{for} & \xi = 0 \\ x \ge \mu - \frac{\sigma}{\xi} & \mbox{for} & \xi > 0 \\ x \le \mu - \frac{\sigma}{\xi} & \mbox{for} & \xi \lt 0 \end{array}\right. $$
p
- a double
, the probability at which to
evaluate the inverse cdfmu
- a double
, the location parametersigma
- a double
, the scale parameterxi
- a double
, the shape parameterdouble
, the p
th quantile x
given the parameter valuespublic static double generalizedGaussian(double p, double mu, double alpha, double beta)
Returns the quantile \(x\) satisfying \(p=F(x)\), where \(p\) is a probability. That is, the function solves for x in $$ p = F(x;\mu,\alpha,\beta) $$ where $$F(x;\mu,\alpha,\beta)=\frac{1}{2} + \frac{sign(x-\mu)}{2\Gamma(\frac{1}{\beta})}\gamma(\frac{1}{\beta},(\frac{|x-\mu|}{\alpha})^{\beta})$$ where \(\mu\) is the location parameter, \(\alpha\) is the scale parameter, \(\beta\) is the shape parameter, and \(\gamma(a,t)\) is the incomplete gamma function with parameter \(a\) evaluated at \(t\). The solution can be shown to be $$ x= sign(p-0.5)\alpha g^{-1}(|2p-1|,\frac{1}{\beta})^{\frac{1}{\beta}} + \mu$$ where \(g^{-1}(u,a)\) is the inverse gamma cumulative distribution function with shape parameter \(a\) evaluated at \(u\).
p
- a double
, the probability at which the
function is to be evaluatedmu
- a double
, the location parameteralpha
- a double
, the scale parameter. It must be positive.beta
- a double
, the shape parameter. It must be positive.double
, the p
th quantile x
given the parameter valuespublic static double generalizedPareto(double p, double mu, double sigma, double alpha)
Returns the quantile \(x\) satisfying \(p=F(x)\), where \(p\) is a probability. That is, the function solves for x in $$ p = F(x; \mu,\sigma, \alpha)$$ where $$ F(x; \mu,\sigma, \alpha) =\left\{\begin{array}{cl} 1 - \left( 1 + \frac{\alpha (x-\mu)}{\sigma}\right)^{(-\frac{1}{\alpha})} & \mbox{for}~ \alpha \ne 0 \\ 1 - \exp(-\frac{x-\mu}{\sigma}) & \mbox{for}~ \alpha = 0 \end{array}\right.$$ where \(\mu \in \mathbb{R} \) is the location parameter, \(\sigma \gt 0 \) is the scale parameter, and \(\alpha \in \mathbb{R} \) is the shape parameter. The support for \(\alpha \ge 0\) is \( x \ge \mu \), while for \( \alpha \lt 0 \), \(\mu \le x \le \mu - \frac{\sigma}{\alpha}\). The solution is easily shown to be $$ x =\left\{\begin{array}{cl} \left(\frac{(1 - p)^{-\alpha}-1}{\alpha}\right)\sigma +\mu & \mbox{for}~ \alpha \ne 0 \\ \mu - \sigma\ln(1-p) & \mbox{for}~ \alpha = 0 \end{array}\right.$$ Note that this follows the parameterization given in Wikipedia.
References
1. Wikipedia contributors. "Generalized Pareto distribution." Wikipedia,
The Free Encyclopedia.
p
- a double
, the probability at which the function is to be
evaluatedmu
- a double
, the location parametersigma
- a double
, the scale parameter. It must be positive.alpha
- a double
, the shape parameterdouble
, the probability density at
x
given the parameter valuespublic static double exponential(double p, double scale)
Method exponential
evaluates the inverse distribution
function of a gamma random variable with scale parameter b and
shape parameter a=1.0. That is, it determines
\(x\) such that
$$p = \frac{1}{{\Gamma \left( a \right)}}\int_o^x {e^{ - t/b} } dt$$
where \(\Gamma(\cdot)\) is the gamma function. The
probability that the random variable takes a value less than or equal to
x is p. See the documentation
for routine gamma
for further discussion of the gamma
distribution.
exponential
uses bisection and modified regula falsi
to invert the distribution function, which is evaluated using method
gamma
.
p
- a double
, the probability at which the
function is to be evaluatedscale
- a double
, the scale parameterdouble
, the p
th quantile x
given the parameter valuespublic static double normal(double p)
Method normal
evaluates the inverse of the
distribution function \(\Phi\) of a standard normal
(Gaussian) random variable, that is, normal
\(({\rm p})=\Phi^{-1}(p)\), where
$$\Phi \left( x \right) = \frac{1}{{\sqrt {2\pi } }}\int_{ - \infty }^x {e^{ - t^2 /2} dt}$$
The value of the distribution function at the point x is the probability that the random variable takes a value less than or equal to x. The standard normal distribution has a mean of 0 and a variance of 1.
p
- a double
, the probability at which the
function is to be evaluateddouble
, the p
th quantile x
given the parameter valuespublic static double chi(double p, double df)
Method chi
evaluates the inverse distribution
function of a chi-squared random variable with df
degrees
of freedom, that is, with P = p and
v = df, it determines x (equal
to chi(p, df)
), such that
$$P = \frac{1}{{2^{\nu /2} \Gamma \left( {\nu /2} \right)}}\int_0^x {e^{ - t/2} t^{\nu /2 - 1} } dt$$
where \(\Gamma(\cdot)\) is the gamma function. The probability that the random variable takes a value less than or equal to x is P.
For \(v \lt 40\), chi
uses
bisection, if \(v \ge 2\) or
\(P \gt 0.98\), or regula falsi to find the point at
which the chi-squared distribution function is equal to P.
The distribution function is evaluated using chi
.
For \(40 \le v \lt 100\), a modified Wilson-Hilferty
approximation (Abramowitz and Stegun 1964, equation 26.4.18) to the
normal distribution is used, and normal
is used to
evaluate the inverse of the normal distribution function. For
\(v \ge 100\), the ordinary Wilson-Hilferty
approximation (Abramowitz and Stegun 1964, equation 26.4.17) is used.
p
- a double
, the probability at which the
function is to be evaluateddf
- a double
, the number of
degrees of freedom. This must be at least 0.5.double
, the p
th quantile x
given the parameter valuespublic static double noncentralF(double p, double dfn, double dfd, double lambda)
If \(X\) is a noncentral chi-square random variable
with noncentrality parameter \(\lambda\) and
\(\nu_1\) degrees of freedom, and \(Y\)
is a chi-square random variable with \(\nu_2\) degrees
of freedom which is statistically independent of \(X\),
then
$$F \;\; = \;\; (X/\nu_1)/(Y/\nu_2)$$
is a noncentral F-distributed random variable whose CDF is given by:
$$CDF(f, \nu_1, \nu_2, \lambda) \;\; = \;\; \int_0^f {PDF(x, \nu_1, \nu_2, \lambda)dx} $$
where the probability density function \(PDF(x, \nu_1, \nu_2, \lambda)\) is given by:
$$PDF(x, \nu_1, \nu_2, \lambda) \;\; = \;\; \Psi \; \sum_{k = 0}^\infty {\Phi_k} $$
$$\Psi \;\; = \;\; \frac{ e^{-\lambda/2}(\nu_1 x)^{\nu_1/2}(\nu_2)^{\nu_2/2} }
{ x \; (\nu_1 x \; + \; \nu_2)^{(\nu_1 + \nu_2)/2} \; \Gamma(\nu_2/2) }$$
$$\Phi_k \;\; = \;\; \frac{ R^k \; \Gamma(\frac{\nu_1 + \nu_2}{2} \; + \; k) }
{ k! \; \Gamma(\frac{\nu_1}{2} \; + \; k) } $$
$$R \;\; = \;\; \frac{ \lambda \nu_1 x }{ 2 (\nu_1 x \; + \; \nu_2)} $$
where \(\Gamma (\cdot)\) is the gamma function,
\(\nu_1\) = dfn
, \(\nu_2\)
= dfd
, \(\lambda\) = lambda
,
and \(p \;\; = \;\; CDF(f, \nu_1, \nu_2, \lambda)\) is
the probability that \(F \le f\).
Method noncentralF
evaluates
$$f \;\; = \;\; CDF^{-1}(p, \nu_1, \nu_2, \lambda)$$
Method noncentralF
uses bisection and modified
regula falsi search algorithms to invert the distribution function
\(CDF(f, \nu_1, \nu_2, \lambda)\), which is evaluated
using method noncentralF
. For sufficiently small p,
an accurate approximation of \(CDF^{-1}(p, \nu_1, \nu_2, \lambda)\)
can be used which requires no such inverse search algorithms.
p
- a double
scalar value representing the
probability for which the inverse of the noncentral
F cumulative distribution function is to be
evaluated. p
must be non-negative and less
than one.dfn
- a double
scalar value representing the number
of numerator degrees of freedom. dfn
must be positive.dfd
- a double
scalar value representing the number
of denominator degrees of freedom. dfd
must be positive.lambda
- a double
scalar value representing the
noncentrality parameter. lambda
must nonnegative.double
, the p
th quantile x
given the parameter valuespublic static double noncentralBeta(double p, double shape1, double shape2, double lambda)
If \(Z\) is a noncentral chi-square random variable with noncentrality parameter \(\lambda\) and \(2 \alpha_1\) degrees of freedom, and \(Y\) is a chi-square random variable with \(2 \alpha_2\) degrees of freedom which is statistically independent of \(Z\), then
$$X \;\; = \;\; \frac{Z}{Z \; + \; Y} \;\; = \;\; \frac{\alpha_1 F}{\alpha_1 F \; + \; \alpha_2}$$
is a noncentral beta-distributed random variable and
$$F \;\; = \;\; \frac{\alpha_2 Z}{\alpha_1 Y} \;\; = \;\; \frac{\alpha_2 X}{\alpha_1 (1 \; - \; X)}$$
is a noncentral F-distributed random variable. The CDF for noncentral beta variable X can thus be simply defined in terms of the noncentral F CDF:
$$CDF_{nc\beta}(x, \; \alpha_1, \; \alpha_2, \; \lambda) \;\; = \;\; CDF_{ncF}(f, \; 2 \alpha_1, \; 2 \alpha_2, \; \lambda)$$
where \(CDF_{nc\beta}(x, \; \alpha_1, \; \alpha_2, \; \lambda)\) is the noncentral beta CDF with \(x\) = x
,
\(\alpha_1\) = shape1
, \(\alpha_2\) = shape2
, and noncentrality parameter
\(\lambda\) = lambda
; \(CDF_{ncF}(f, \; 2 \alpha_1, \; 2 \alpha_2, \; \lambda)\) is the noncentral F CDF
with argument f, numerator and denominator degrees of freedom \(2 \alpha_1\) and \(2 \alpha_2\)
respectively, and noncentrality parameter \(\lambda\); and:
$$f \;\; = \;\; \frac{\alpha_2 x}{\alpha_1 (1 \; - \; x)}; \;\; x \;\; = \;\; \frac{\alpha_1 f}{\alpha_1 f \; + \; \alpha_2}$$
(See documentation for class Cdf
method noncentralF
for a discussion of how the noncentral F CDF
is defined and calculated.)
Method noncentralBeta
evaluates
$$x \;\; = \;\; CDF_{nc\beta}^{-1}(p, \; \alpha_1, \; \alpha_2, \; \lambda)$$
by first evaluating:
$$f \;\; = \;\; CDF_{ncF}^{-1}(p, \; 2 \alpha_1, \; 2 \alpha_2, \; \lambda)$$
and then solving for x using \(x \;\; = \;\; \frac{\alpha_1 f}{\alpha_1 f \; + \; \alpha_2}\).
(See documentation for class Cdf
method noncentralF
for a discussion of how the inverse
noncentral F CDF is calculated.)
p
- a double
scalar value representing the probability for which the inverse of the noncentral beta
cumulative distribution function is to be evaluated.
p
must be non-negative and less than or equal to one.shape1
- a double
scalar value representing the first shape parameter.
shape1
must be positive.shape2
- a double
scalar value representing the second shape parameter.
shape2
must be positive.lambda
- a double
scalar value representing the noncentrality parameter.
lambda
must be nonnegative.double
, the p
th quantile x
given the parameter values.public static double noncentralchi(double p, double df, double alam)
Method noncentralchi
evaluates the inverse distribution
function of a noncentral chi-squared random variable with df
degrees
of freedom and noncentrality parameter alam
, that is, with P = p,
\(\nu = {\rm df}\), and \(\lambda = {\rm alam}\), it
determines \(c_{0} = \) noncentralchi(p, df, alam)
), such that
$$P = \sum\limits_{i = 0}^\infty {\frac{e^{-\lambda/2}\left(\lambda/2\right)^i}{i!}} \int_0^{c_{0}} {\frac{x^{\left(\nu + 2i\right)/2-1}e^{ - x/2}} {2^{\left(\nu+2i\right)/2}{\Gamma\left(\frac{\nu+2i}{2}\right)}}} dx$$
where \(\Gamma (\cdot)\) is the gamma function. The probability that the random variable takes a value less than or equal to \(c_{0}\) is \(P\).
Method noncentralchi
uses bisection and modified regula falsi to invert the distribution
function, which is evaluated using noncentralchi
. See noncentralchi
for an
alternative definition of the noncentral chi-squared random variable in terms of normal random variables.
p
- a double
, the probability at which the
function is to be evaluateddf
- a double
, the number of
degrees of freedom. This must be at least 0.5 but
less than or equal to 200,000.alam
- a double
, the noncentrality
parameter. This must be nonnegative, and alam + df
must be less than or equal to 200,000.double
, the p
th quantile x
given the parameter valuespublic static double studentsT(double p, double df)
studentsT
evaluates the inverse distribution
function of a Student's t random variable with
df
degrees of freedom. Let v = df. If
v equals 1 or
2, the inverse can be obtained in closed form, if
v is between 1 and 2, the relationship of a
t to a beta random variable is exploited and
beta
is used to evaluate the inverse; otherwise the
algorithm of Hill (1970) is used. For small values of v
greater than 2, Hill's algorithm inverts an integrated expansion in
\(1/(1 + t^2/v)\) of the t density.
For larger values, an asymptotic inverse Cornish-Fisher type expansion
about normal deviates is used.
p
- a double
, the probability at which the
function is to be evaluateddf
- a double
scalar value representing the number of
degrees of freedom. This must be at least one.double
, the p
th quantile x
given the parameter valuespublic static double noncentralstudentsT(double p, int idf, double delta)
Method noncentralstudentsT
evaluates the inverse distribution function
of a noncentral t random variable with idf
degrees of freedom and noncentrality parameter delta
; that is, with
\(\nu = idf\), \(\delta = delta\), it determines \(t_{0} = \) noncentralstudentsT(p, idf, delta)
), such that
$$p = \int_{-{\infty}}^{t_{0}}{\frac{\nu^{\nu/2}e^{{-\delta^2}/2}} {{\sqrt{\pi}\Gamma\left(\nu/2\right)\left(\nu+x^2\right)}^{\left(\nu+1\right)/2}} } \sum\limits_{i = 0}^\infty {\Gamma\left(\left(\nu+i+1\right)/2\right)\left(\frac{\delta^i}{i!}\right) \left(\frac{2x^2}{\nu+x^2}\right)^{i/2} dx}$$
where \(\Gamma (\cdot)\) is the gamma function.
The probability that the random variable takes a value less than or
equal to \(t_{0}\) is P
. See noncentralstudentsT
for an alternative
definition in terms of normal and chi-squared random variables. The method noncentralstudentsT
uses bisection and modified regula falsi to invert the distribution function, which is evaluated using
noncentralstudentsT
.
p
- a double
, the probability at which the
function is to be evaluatedidf
- an int
, the number of
degrees of freedom. This must be positive.delta
- a double
, the noncentrality
parameterdouble
, the p
th quantile x
given the parameter valuespublic static double Weibull(double p, double gamma, double alpha)
p
- a double
, the probability at which the
function is to be evaluatedgamma
- a double
, the shape parameteralpha
- a double
, the scale parameterdouble
, the p
th quantile x
given the parameter valuespublic static double logNormal(double p, double mu, double sigma)
p
- a double
, the probability at which the function is
to be evaluatedmu
- a double
, the location parametersigma
- a double
, the shape parameter.
sigma
must be a positive.double
, the p
th quantile
x
given the parameter valuespublic static double extremeValue(double p, double mu, double beta)
p
- a double
, the probability at which the function is
to be evaluatedmu
- a double
, the location parameterbeta
- a double
, the scale parameterdouble
, the p
th quantile x
given the parameter valuespublic static double Rayleigh(double p, double alpha)
p
- a double
, the probability at which the function is
to be evaluatedalpha
- a double
, the scale parameterdouble
, the p
th quantile
x
given the parameter valuespublic static double uniform(double p, double aa, double bb)
InvCdf.continuousUniform(double, double, double)
insteadp
- a double
, the probability at which the function is
to be evaluatedaa
- a double
, the minimum valuebb
- a double
, the maximum valuedouble
, the p
th quantile x
given the parameter valuespublic static double continuousUniform(double p, double a, double b)
p
- a double
, the probability at which to evaluate
the inverse cdfa
- a double
, the lower parameter \(a\)b
- a double
, the upper parameter \(b\)double
, the p
th quantile x
given the parameter valuespublic static int discreteUniform(double p, int n)
p
- a double
, the probability at which the function is
to be evaluatedn
- an int
, the
upper limit of the discrete uniform distributiondouble
, the p
th quantile x
given the parameter valuespublic static double geometric(double r, double pin)
r
- a double
, the probability for which the inverse
geometric function is to be evaluatedpin
- a double
, the probability parameter
for each independent trial (the probability of success for each
independent trial)double
, the p
th quantile x
given the parameter valuespublic static double logistic(double p, double mu, double sigma)
p
- a double
, the probability at which the function is
to be evaluatedmu
- a double
, the location parametersigma
- a double
, the scale parameterdouble
, the p
th quantile
x
given the parameter valuespublic static double Pareto(double p, double xm, double k)
p
- a double
, the probability at which the function is
to be evaluatedxm
- a double
,the scale parameterk
- a double
, the shape parameterdouble
, the p
th quantile x
given the parameter valuesCopyright © 2020 Rogue Wave Software. All rights reserved.