udhyper function

UNU.RAN object for Hypergeometric distribution

UNU.RAN object for Hypergeometric distribution

Create UNU.RAN object for a Hypergeometric distribution with parameters m, n, and k.

[Distribution] -- Hypergeometric.

udhyper(m, n, k, lb=max(0,k-n), ub=min(k,m))

Arguments

  • 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.
  • lb: lower bound of (truncated) distribution.
  • ub: upper bound of (truncated) distribution.

Details

The Hypergeometric distribution is used for sampling without

replacement. The density of this distribution with parameters m, n and k (named NpNp, NNpN-Np, and nn, respectively in the reference below) is given by

p(x)=(mx)(nkx)/(m+nk)p(x)=choose(m,x)choose(n,kx)/choose(m+n,k) p(x) = \left. {m \choose x}{n \choose k-x} \right/ {m+n \choose k}p(x) = choose(m, x) choose(n, k-x) / choose(m+n, k)

for x=0,,kx = 0, \ldots, k.

The domain of the distribution can be truncated to the interval (lb,ub).

Returns

An object of class "unuran.discr".

References

N.L. Johnson, S. Kotz, and A.W. Kemp (1992): Univariate Discrete Distributions. 2nd edition, John Wiley & Sons, Inc., New York. Chap. 6, p. 237.

Author(s)

Josef Leydold and Wolfgang H"ormann unuran@statmath.wu.ac.at .

Examples

## Create distribution object for Hypergeometric distribution dist <- udhyper(m=15,n=5,k=7) ## Generate generator object; use method DGT (inversion) gen <- dgtd.new(dist) ## Draw a sample of size 100 x <- ur(gen,100)
  • Maintainer: Josef Leydold
  • License: GPL (>= 2)
  • Last published: 2025-04-07