Learn R Programming

DPQ (version 0.5-3)

phyperR: R-only version of R's original phyper() algorithm

Description

An R version of the first phyper() algorithm in R, which was used up to svn rev 30227 on 2004-07-09.

Usage


phyperR(q, m, n, k)

Value

a numeric vector similar to phyper(q, m, n, k).

Arguments

q

vector of quantiles representing the number of white balls drawn without replacement from an urn which contains both black and white balls.

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 \(0,1,\dots, m+n\).

Author

Martin Maechler

See Also

Examples

Run this code
m <- 9:12; n <- 7:10; k <- 10
x <- 0:(k+1) # length 12
for(. in 0:11) stopifnot(
  all.equal(phyper (., m=10, n=8, k=10),
            phyperR(., m=10, n=8, k=10), tol=1e-12))
## BUT the vectorization fails badly : FIXME! %% <<<<<< FIXME <<<<<<<<<<<<<<<
(A <- cbind(x, m, n, k)) # shows the recycling
cbind(A, ph = phyper (x, m, n, k),
      phR   = phyperR(x, m, n, k))

Run the code above in your browser using DataLab