phyperApprAS152 | R Documentation |
Compute the normal approximation (via pnorm(.)
from AS 152
to the cumulative hyperbolic distribution function phyper()
.
phyperApprAS152(q, m, n, k)
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
|
a numeric
vector of the same length (etc) as q
.
I have Fortran (and C code translated from Fortran) which says
ALGORITHM AS R77 APPL. STATIST. (1989), VOL.38, NO.1 Replaces AS 59 and AS 152 Incorporates AS R86 from vol.40(2)
Martin Maechler, 19 Apr 1999
Lund, Richard E. (1980) Algorithm AS 152: Cumulative Hypergeometric Probabilities. Journal of the Royal Statistical Society. Series C (Applied Statistics), 29(2), 221–223. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.2307/2986315")}
Shea, B. (1989) Remark AS R77: A Remark on Algorithm AS 152: Cumulative Hypergeometric Probabilities. JRSS C (Applied Statistics), 38(1), 199–204. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.2307/2347696")}
Berger, R. (1991) Algorithm AS R86: A Remark on Algorithm AS 152: Cumulative Hypergeometric Probabilities. JRSS C (Applied Statistics), 40(2), 374–375. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.2307/2347606")}
phyper
##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (q, m, n, k)
{
kk <- n
nn <- m
mm <- m + n
ll <- q
mean <- kk * nn/mm
sig <- sqrt(mean * (mm - nn)/mm * (mm - kk)/(mm - 1))
pnorm(ll + 1/2, mean = mean, sd = sig)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.