.suppHyper # very simple:
stopifnot(identical(.suppHyper, ignore.environment = TRUE,
function (m, n, k) max(0, k-n):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
Run the code above in your browser using DataLab