Skip to content

Commit

Permalink
update quantile function
Browse files Browse the repository at this point in the history
closes #50
  • Loading branch information
spinkney committed Nov 14, 2021
1 parent ae039bc commit 7c3f956
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
9 changes: 0 additions & 9 deletions functions/inverse_cdf/icdf_definition.stan

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/** @addtogroup johnson_quantile_icdf Johnson Quantile Parameterized Distributions (J-QPD) functions
/** @addtogroup johnson_qf Johnson Quantile Parameterized Distributions (J-QPD) functions
*
* Christopher C. Hadlock, J. Eric Bickel
* The Generalized Johnson Quantile-Parameterized Distribution System.
* Decision Analysis 16 (1) 67-85 https://doi.org/10.1287/deca.2018.0376
*
* \ingroup icdf
* \ingroup qf
* @{ */

/**
* Inverse CDF of the J-QPD-S semi-bounded distribution, which has moments
* Quantile function of the J-QPD-S semi-bounded distribution, which has moments
*
* \f{aligned}{
* F^{-1}(p, l, x_\alpha) =
Expand Down Expand Up @@ -45,7 +45,7 @@
* @throws reject if \f$ \alpha \notin [0, 1] \f$
* @throws reject if quantiles \f$ \ne 3\f$
*/
real JQPDS_icdf(real p, real lower_bound, data real alpha, vector quantiles) {
real JQPDS_qf(real p, real lower_bound, data real alpha, vector quantiles) {
if (p < 0 || p > 1) reject("p must be between 0 and 1");
if (alpha < 0 || alpha > 1) reject("alpha must be between 0 and 1");
if (rows(quantiles) != 3) reject("quantiles must have three elements");
Expand Down Expand Up @@ -88,7 +88,7 @@
}

/**
* Inverse CDF of the J-QPD-S-II semi-bounded distribution, which lacks moments
* Quantile function of the J-QPD-S-II semi-bounded distribution, which lacks moments
*
* \f{aligned}{
* F^{-1}(p, l, x_\alpha) =
Expand Down Expand Up @@ -124,7 +124,7 @@
* @throws reject if \f$ \alpha \notin [0, 1] \f$
* @throws reject if quantiles \f$ \ne 3\f$
*/
real JQPDS2_icdf(real p, real lower_bound, data real alpha, vector quantiles) {
real JQPDS2_qf(real p, real lower_bound, data real alpha, vector quantiles) {
if (p < 0 || p > 1) reject("p must be between 0 and 1");
if (alpha < 0 || alpha > 1) reject("alpha must be between 0 and 1");
if (rows(quantiles) != 3) reject("quantiles must have three elements");
Expand Down Expand Up @@ -158,7 +158,7 @@
}

/**
* Inverse CDF of the J-QPD-B bounded distribution
* Quantile function of the J-QPD-B bounded distribution
*
* \f{aligned}{
* F^{-1}(p, u, l, x_\alpha) =
Expand Down Expand Up @@ -195,7 +195,7 @@
* @throws reject if \f$ \alpha \notin [0, 1] \f$
* @throws reject if quantiles \f$ != 3\f$
*/
real JQPDB_icdf(real p, row_vector bounds, data real alpha, vector quantiles) {
real JQPDB_qf(real p, row_vector bounds, data real alpha, vector quantiles) {
if (cols(bounds) != 2) reject("bounds must have two elements");
if (bounds[2] == positive_infinity()) {
return JQPDS2_icdf(p, alpha, bounds[1], quantiles);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @ingroup icdf
* **Lognormal Inverse CDF**
/** @ingroup qf
* **Lognormal Quantile Function**
*
* \f{aligned}{
* F^{-1}(p) &= \exp(\mu + \sqrt{2} \, \sigma \, \text{inv_erf}(2p - 1)) \\
Expand All @@ -20,7 +20,7 @@
* @return inverse CDF value
* @throws reject if \f$ p \notin [0, 1] \f$
*/
real lognormal_icdf (real p, real mu, real sigma){
real lognormal_qf (real p, real mu, real sigma){
if (is_nan(p) || p < 0 || p > 1)
reject("lognormal_icdf: p must be between 0 and 1; ",
"found p = ", p);
Expand Down
9 changes: 9 additions & 0 deletions functions/quantile_function/qf_definition.stan
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** \defgroup qf Quantile Functions also known as Inverse Cumulative Distribution Functions
*
* In probability and statistics, the quantile function - also known as
* an inverse cumulative distribution function - is, associated with a probability distribution of a random variable, specifies
* the value of the random variable such that the probability of the variable being less than or equal
* to that value equals the given probability.
*
* See https://en.wikipedia.org/wiki/Quantile_function for more information.
**/
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include special/inc_beta_inverse.stan

/** @ingroup icdf
* Skewed generalized T inverse CDF
/** @ingroup qf
* Skewed Generalized T Quantile Function
*
*
* For more information, please see @ref skew_generalized_t.
Expand All @@ -16,7 +16,7 @@
* @param q Real \f$\in (0, \infty)\f$ kurtosis parameter
* @return log probability
*/
real skewed_generalized_t_icdf (real p, real mu, real sigma, real lambda, real p, real q) {
real skewed_generalized_t_qf (real p, real mu, real sigma, real lambda, real p, real q) {
real z1 = beta(1.0 / p, q);
real z2 = beta(2.0 / p, q - 1.0 / p);
real v = sigma * q^(-1.0/p) * inv_sqrt( ( 3 * square(lambda) + 1 ) * beta(3.0/p, q - 2.0/p) / z1 - 4 * square(lambda * z2 / z1) );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @ingroup icdf
* Unit Johnson SU Inverse CDF
/** @ingroup qf
* Unit Johnson SU Quantile Function
*
* \f{aligned}{
* F^{-1}(p, \, \mu, \, \sigma) &= \text{inv_logit}\bigg[ \sinh\bigg(\frac{\Phi^{-1}(p) - \mu}{\sigma}\bigg) \bigg]\\
Expand All @@ -12,7 +12,7 @@
* @return inverse CDF value
* @throws reject if \f$ p \notin [0, 1] \f$
*/
real unit_johnson_icdf (real p, real mu, real sigma){
real unit_johnson_qf (real p, real mu, real sigma){
if (is_nan(p) || p < 0 || p > 1)
reject("unit_johnson_icdf: p must be between 0 and 1; ",
"found p = ", p);
Expand Down

0 comments on commit 7c3f956

Please sign in to comment.