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

phyperR {DPQ} | R Documentation

## 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)

### 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,…, m+n.

### Value

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

### Note

The original argument list in `C` was `(x, NR, NB, n)` where there were red and black balls in the urn.

Note that we have vectorized a translation to R of the original C code.

### Author(s)

Martin Maechler

### See Also

`phyper`.

### Examples

    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))

[Package DPQ version 0.4-4 Index]