phyperPeizer | R Documentation |
Compute Peizer's extremely good normal approximation to the cumulative hyperbolic distribution.
This implementation corrects a typo in the reference.
phyperPeizer(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, with the length the maximum of the
lengths of q, m, n, k
.
Martin Maechler
Johnson, Kotz & Kemp (1992): (6.93) & (6.94), p.261 CORRECTED by M.M.
phyper
.
## The function is defined as
phyperPeizer <- function(q, m, n, k)
{
## Purpose: Peizer's extremely good Normal Approx. to cumulative Hyperbolic
## Johnson, Kotz & Kemp (1992): (6.93) & (6.94), p.261 __CORRECTED__
## ----------------------------------------------------------------------
Np <- m; N <- n + m; n <- k; x <- q
## (6.94) -- in proper order!
nn <- Np ; n. <- Np + 1/6
mm <- N - Np ; m. <- N - Np + 1/6
r <- n ; r. <- n + 1/6
s <- N - n ; s. <- N - n + 1/6
N. <- N - 1/6
A <- x + 1/2 ; A. <- x + 2/3
B <- Np - x - 1/2 ; B. <- Np - x - 1/3
C <- n - x - 1/2 ; C. <- n - x - 1/3
D <- N - Np - n + x + 1/2 ; D. <- N - Np - n + x + 2/3
n <- nn
m <- mm
## After (6.93):
L <-
A * log((A*N)/(n*r)) +
B * log((B*N)/(n*s)) +
C * log((C*N)/(m*r)) +
D * log((D*N)/(m*s))
## (6.93) :
pnorm((A.*D. - B.*C.) / abs(A*D - B*C) *
sqrt(2*L* (m* n* r* s* N.)/
(m.*n.*r.*s.*N )))
# The book wrongly has an extra "2*" before `m* ' (after "2*L* (" ) above
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.