phyperAllBin {DPQ}  R Documentation 
Compute Hypergeometric Probabilities via Binomial Approximations
Description
Simple utilities for ease of comparison of the different
phyper
approximation in package DPQ:

phyperAllBinM()
computes all four Molenaar binomial approximations to the hypergeometric cumulative distribution functionphyper()
. 
phyperAllBin()
computes Molenaar's four and additionally the other fourphyperBin.1()
,*.2
,*.3
, and*.4
. 
.suppHyper()
, support of the Hyperbolic, is a simple 1liner, providing all sensible integer values for the first argumentq
(or alsox
) of the hyperbolic probability functions (dhyper()
andphyper()
), and their approximations (here in DPQ).
Usage
phyperAllBin (m, n, k, q = .suppHyper(m, n, k), lower.tail = TRUE, log.p = FALSE)
phyperAllBinM(m, n, k, q = .suppHyper(m, n, k), lower.tail = TRUE, log.p = FALSE)
.suppHyper(m, n, k)
Arguments
m 
the number of white balls in the urn. 
n 
the number of black balls in the urn. 
k 
the number of balls drawn from the urn, hence must be in 
q 
vector of quantiles representing the number of white balls
drawn without replacement from an urn which contains both black and
white balls. The default, 
lower.tail 
logical; if TRUE (default), probabilities are

log.p 
logical; if TRUE, probabilities p are given as log(p). 
Value
the phyperAllBin*()
functions return
a numeric matrix
, with each column a different
approximation to phyper(m,n,k,q, lower.tail, log.p)
.
Note that the columns of phyperAllBinM()
are a subset of
those from phyperAllBin()
.
Author(s)
Martin Maechler
References
See those in phyperBinMolenaar
.
See Also
phyperBin.1
etc, and
phyperBinMolenaar
.
Examples
.suppHyper # very simple:
stopifnot(identical(.suppHyper, ignore.environment = TRUE,
function (m, n, k) max(0, kn):min(k, m)))
phBall < phyperAllBin (5,15, 7)
phBalM < phyperAllBinM(5,15, 7)
stopifnot(identical( ## indeed, ph...AllBinM() gives a *subset* of ph...AllBin():
phBall[, colnames(phBalM)] ,
phBalM)
, .suppHyper(5, 15, 7) == 0:5
)
round(phBall, 4)
cbind(q = 0:5, round(log10(abs(1  phBall / phyper(0:5, 5,15,7))), digits=2))
require(sfsmisc)## > relErrV() {and eaxis()}:
qq < .suppHyper(20, 47, 31)
phA < phyperAllBin(20, 47, 31)
rE < relErrV(target = phyper(qq, 20,47,31), phA)
signif(cbind(qq, rE), 4)
## Relative approximation error [ log scaled ] :
matplot(qq, abs(rE), type="b", log="y", yaxt="n")
eaxis(2)
## > approximations useful only "on the right", aka the right tail