R: Density, Probability, Quantile ('DPQ') Computations

DPQ-package {DPQ} | R Documentation

## Density, Probability, Quantile ('DPQ') Computations

### Description

Computations for approximations and alternatives for the 'DPQ' (Density (pdf), Probability (cdf) and Quantile) functions for probability distributions in R. Primary focus is on (central and non-central) beta, gamma and related distributions such as the chi-squared, F, and t. – This is for the use of researchers in these numerical approximation implementations, notably for my own use in order to improve standard R pbeta(), qgamma(), ..., etc: {'"dpq"'-functions}.

### Details

The DESCRIPTION file:

Package: | DPQ
Title: | Density, Probability, Quantile ('DPQ') Computations
Version: | 0.5-2
Date: | 2022-06-08
Authors@R: | c(person("Martin","Maechler", role=c("aut","cre"), email="maechler@stat.math.ethz.ch", comment = c(ORCID = "0000-0002-8685-9910")) , person("Morten", "Welinder", role = "ctb", comment = "pgamma C code, see PR#7307, Jan. 2005; further pdhyper()") , person("Wolfgang", "Viechtbauer", role = "ctb", comment = "dtWV(), 2002") , person("Ross", "Ihaka", role = "ctb", comment = "src/qchisq_appr.c") , person("Marius", "Hofert", role = "ctb", comment = "lsum(), lssum()") , person("R-core", email = "R-core@R-project.org", role = "ctb", comment = "src/{dpq.h, algdiv.c, pnchisq.c, bd0.c}") , person("R Foundation", role = "cph", comment = "src/qchisq-appr.c") )
Description: | Computations for approximations and alternatives for the 'DPQ' (Density (pdf), Probability (cdf) and Quantile) functions for probability distributions in R. Primary focus is on (central and non-central) beta, gamma and related distributions such as the chi-squared, F, and t. -- This is for the use of researchers in these numerical approximation implementations, notably for my own use in order to improve standard R pbeta(), qgamma(), ..., etc: {'"dpq"'-functions}.
Depends: | R (>= 3.6.0)
Imports: | stats, graphics, methods, utils, sfsmisc (>= 1.1-13)
Suggests: | Rmpfr, DPQmpfr (>= 0.3-1), gmp, MASS, mgcv, scatterplot3d, interp
SuggestsNote: | MASS::fractions() in ex | mgcv, scatt.., interp: some tests/
License: | GPL (>= 2)
Encoding: | UTF-8
URL: | https://specfun.r-forge.r-project.org/, https://r-forge.r-project.org/R/?group_id=611
BugReports: | https://r-forge.r-project.org/tracker/?atid=2462&group_id=611
Author: | Martin Maechler [aut, cre] (<https://orcid.org/0000-0002-8685-9910>), Morten Welinder [ctb] (pgamma C code, see PR#7307, Jan. 2005; further pdhyper()), Wolfgang Viechtbauer [ctb] (dtWV(), 2002), Ross Ihaka [ctb] (src/qchisq_appr.c), Marius Hofert [ctb] (lsum(), lssum()), R-core [ctb] (src/{dpq.h, algdiv.c, pnchisq.c, bd0.c}), R Foundation [cph] (src/qchisq-appr.c)
Maintainer: | Martin Maechler <maechler@stat.math.ethz.ch>

Index of help topics:

    Bern                    Bernoulli Numbers
    DPQ-package             Density, Probability, Quantile ('DPQ')
                            Computations
    M_LN2                   Numerical Utilities - Functions, Constants
    algdiv                  Compute log(gamma(b)/gamma(a+b)) when b >= 8
    b_chi                   Compute E[chi_nu]/sqrt(nu) useful for t- and
                            chi-Distributions
    bd0                     Utility Functions for 'dgamma()' - Pure R
                            Versions
    bpser                   'pbeta()' 'bpser' series computation
    dbinom_raw              R's C Mathlib (Rmath) dbinom_raw() Binomial
                            Probability pure R Function
    dgamma.R                Gamma Density Function Alternatives
    dhyperBinMolenaar       HyperGeometric (Point) Probabilities via
                            Molenaar's Binomial Approximation
    dnbinomR                Pure R Versions of R's C (Mathlib) dnbinom()
                            Negative Binomial Probabilities
    dnchisqR                Approximations of the (Noncentral) Chi-Squared
                            Density
    dntJKBf1                Non-central t-Distribution Density - Algorithms
                            and Approximations
    dpsifn                  Psi Gamma Functions Workhorse from R's API
    dtWV                    Noncentral t Distribution Density by W.V.
    format01prec            Format Numbers in [0,1] with "Precise" Result
    frexp                   Base-2 Representation and Multiplication of
                            Numbers
    hyper2binomP            Transform Hypergeometric Distribution
                            Parameters to Binomial Probability
    lbetaM                  (Log) Beta Approximations
    lfastchoose             R versions of Simple Formulas for Logarithmic
                            Binomial Coefficients
    lgamma1p                Accurate 'log(gamma(a+1))'
    lgammaAsymp             Asymptotic Log Gamma Function
    log1mexp                Compute log(1 - exp(-a)) and log(1 + exp(x))
                            Numerically Optimally
    log1pmx                 Accurate 'log(1+x) - x' Computation
    logcf                   Continued Fraction Approximation of Log-Related
                            Power Series
    logspace.add            Logspace Arithmetix - Addition and Subtraction
    lssum                   Compute Logarithm of a Sum with Signed Large
                            Summands
    lsum                    Properly Compute the Logarithm of a Sum (of
                            Exponentials)
    newton                  Simple R level Newton Algorithm, Mostly for
                            Didactical Reasons
    p1l1                    Numerically Stable p1l1(t) = (t+1)*log(1+t) - t
    pbetaRv1                Pure R Implementation of Old pbeta()
    pchisqV                 Wienergerm Approximations to (Non-Central)
                            Chi-squared Probabilities
    phyper1molenaar         Molenaar's Normal Approximations to the
                            Hypergeometric Distribution
    phyperAllBin            Compute Hypergeometric Probabilities via
                            Binomial Approximations
    phyperApprAS152         Normal Approximation to cumulative Hyperbolic
                            Distribution - AS 152
    phyperBin.1             HyperGeometric Distribution via Approximate
                            Binomial Distribution
    phyperBinMolenaar       HyperGeometric Distribution via Molenaar's
                            Binomial Approximation
    phyperIbeta             Pearson's incomplete Beta Approximation to the
                            Hyperbolic Distribution
    phyperPeizer            Peizer's Normal Approximation to the Cumulative
                            Hyperbolic
    phyperR                 R-only version of R's original phyper()
                            algorithm
    phyperR2                Pure R version of R's C level phyper()
    phypers                 The Four (4) Symmetric phyper() calls.
    pl2curves               Plot 2 Noncentral Distribution Curves for
                            Visual Comparison
    pnbetaAppr2             Noncentral Beta Probabilities
    pnchi1sq                (Probabilities of Non-Central Chi-squared
                            Distribution for Special Cases
    pnchisq                 (Approximate) Probabilities of Non-Central
                            Chi-squared Distribution
    pnormAsymp              Asymptotic Approxmation of (Extreme Tail)
                            'pnorm()'
    pnormL_LD10             Bounds for 1-Phi(.) - Mill's Ratio related
                            Bounds for pnorm()
    pntR                    Non-central t Probability Distribution -
                            Algorithms and Approximations
    ppoisErr                Direct Computation of 'ppois()' Poisson
                            Distribution Probabilities
    qbetaAppr               Compute (Approximate) Quantiles of the Beta
                            Distribution
    qbinomR                 Pure R Implementation of R's qbinom() with
                            Tuning Parameters
    qchisqAppr              Compute Approximate Quantiles of the
                            Chi-Squared Distribution
    qgammaAppr              Compute (Approximate) Quantiles of the Gamma
                            Distribution
    qnbinomR                Pure R Implementation of R's qnbinom() with
                            Tuning Parameters
    qnchisqAppr             Compute Approximate Quantiles of Noncentral
                            Chi-Squared Distribution
    qnormAppr               Approximations to 'qnorm()', i.e., z_alpha
    qnormR                  Pure R version of R's 'qnorm()' with
                            Diagnostics and Tuning Parameters
    qpoisR                  Pure R Implementation of R's qpois() with
                            Tuning Parameters
    qtAppr                  Compute Approximate Quantiles of Non-Central t
                            Distribution
    r_pois                  Compute Relative Size of i-th term of Poisson
                            Distribution Series

Further information is available in the following vignettes:

`Noncentral-Chisq` | Noncentral Chi-Squared Probabilities -- Algorithms in R (source)
`comp-beta` | Computing Beta(a,b) for Large Arguments (source)
`log1pmx-etc` | log1pmx, bd0, stirlerr - Probability Computations in R (source)

An important goal is to investigate diverse algorithms and approximations of R's own density (`d*()`), probability (`p*()`), and quantile (`q*()`) functions, notably in “border” cases where the traditional published algorithms have shown to be suboptimal, not quite accurate, or even useless.

Examples are border cases of the beta distribution, or non-central distributions such as the non-central chi-squared and t-distributions.

### Author(s)

Principal author and maintainer: NA

### See Also

The package DPQmpfr (not yet on CRAN), which builds on this package and on Rmpfr.

### Examples

    ## Show problem in R's non-central t-distrib. density (and approximations):
    example(dntJKBf)

[Package DPQ version 0.5-2 Index]