|
1 | 1 | # functions related to hyper-geometric distribution |
2 | 2 |
|
3 | | -# R implementations |
4 | | -using .RFunctions: |
5 | | - hyperpdf, |
6 | | - hyperlogpdf, |
7 | | - hypercdf, |
8 | | - hyperccdf, |
9 | | - hyperlogcdf, |
10 | | - hyperlogccdf, |
11 | | - hyperinvcdf, |
12 | | - hyperinvccdf, |
13 | | - hyperinvlogcdf, |
14 | | - hyperinvlogccdf |
| 3 | +# Rmath implementations |
| 4 | +function hyperpdf(ms::Real, mf::Real, n::Real, x::Real) |
| 5 | + T = float(Base.promote_typeof(ms, mf, n, x)) |
| 6 | + return convert(T, Rmath.dhyper(x, ms, mf, n, false)) |
| 7 | +end |
| 8 | +function hyperlogpdf(ms::Real, mf::Real, n::Real, x::Real) |
| 9 | + T = float(Base.promote_typeof(ms, mf, n, x)) |
| 10 | + return convert(T, Rmath.dhyper(x, ms, mf, n, true)) |
| 11 | +end |
| 12 | + |
| 13 | +function hypercdf(ms::Real, mf::Real, n::Real, x::Real) |
| 14 | + T = float(Base.promote_typeof(ms, mf, n, x)) |
| 15 | + return convert(T, Rmath.phyper(x, ms, mf, n, true, false)) |
| 16 | +end |
| 17 | +function hyperccdf(ms::Real, mf::Real, n::Real, x::Real) |
| 18 | + T = float(Base.promote_typeof(ms, mf, n, x)) |
| 19 | + return convert(T, Rmath.phyper(x, ms, mf, n, false, false)) |
| 20 | +end |
| 21 | +function hyperlogcdf(ms::Real, mf::Real, n::Real, x::Real) |
| 22 | + T = float(Base.promote_typeof(ms, mf, n, x)) |
| 23 | + return convert(T, Rmath.phyper(x, ms, mf, n, true, true)) |
| 24 | +end |
| 25 | +function hyperlogccdf(ms::Real, mf::Real, n::Real, x::Real) |
| 26 | + T = float(Base.promote_typeof(ms, mf, n, x)) |
| 27 | + return convert(T, Rmath.phyper(x, ms, mf, n, false, true)) |
| 28 | +end |
| 29 | + |
| 30 | +function hyperinvcdf(ms::Real, mf::Real, n::Real, q::Real) |
| 31 | + T = float(Base.promote_typeof(ms, mf, n, q)) |
| 32 | + return convert(T, Rmath.qhyper(q, ms, mf, n, true, false)) |
| 33 | +end |
| 34 | +function hyperinvccdf(ms::Real, mf::Real, n::Real, q::Real) |
| 35 | + T = float(Base.promote_typeof(ms, mf, n, q)) |
| 36 | + return convert(T, Rmath.qhyper(q, ms, mf, n, false, false)) |
| 37 | +end |
| 38 | +function hyperinvlogcdf(ms::Real, mf::Real, n::Real, lq::Real) |
| 39 | + T = float(Base.promote_typeof(ms, mf, n, lq)) |
| 40 | + return convert(T, Rmath.qhyper(lq, ms, mf, n, true, true)) |
| 41 | +end |
| 42 | +function hyperinvlogccdf(ms::Real, mf::Real, n::Real, lq::Real) |
| 43 | + T = float(Base.promote_typeof(ms, mf, n, lq)) |
| 44 | + return convert(T, Rmath.qhyper(lq, ms, mf, n, false, true)) |
| 45 | +end |
0 commit comments