hyper_param: Parameters for Hypergeometric Distributions

hyper_paramR Documentation

Parameters for Hypergeometric Distributions

Description

Generates a data frame with potential values for m, n and k. If hyper2 is FALSE then the parametrization of stats::dhyper() is used, otherwise n+m, m and k is used and transformed to m, n and k. In accordance with specific conditions it holds that:

  • if length(mean)==1 and it's an integer, it signifies the desired number of digits for the mean

  • if mean is set to NA (the default), all means are permissible

  • when length(mean) > 1, the product k*m/(n+m) must be one of the valid means

  • the same rules apply to sd

The parameters norm, pois and binom can take on the values NA, TRUE, FALSE, or be defined as a function of the format: ⁠function(m, n, k)⁠. These values determine which ⁠(m, n, k)⁠ combinations are eligible:

  • for NA, all combinations of ⁠(m, n, k)⁠ are acceptable

  • if specified as a function, only those combinations for which the function evaluates to TRUE are considered valid

  • if set to TRUE, combinations are accepted only if they satisfy either the condition k*m/(m+n)*(1-m/(m+n))>=9 (for norm, indicating a normal distribution approximation), the conditions k/(n+m) < 0.05, m/(n+m) < 0.05 and k>10 (for pois, implying a Poisson distribution approximation) and the condition k/(n+m) < 0.05 (for binom, implying a binomial distribution approximation)

  • if set to FALSE, the approximations should not hold for any combination.

Please be aware that there is no guarantee that the resulting data frame will include a valid solution.

Usage

hyper_param(
  m,
  n,
  k,
  mean = NA,
  sd = NA,
  norm = NA,
  pois = NA,
  binom = NA,
  tol = 1e-06,
  hyper2 = FALSE
)

Arguments

m

numeric: the number of white balls in the urn

n

numeric: the number of black balls in the urn

k

numeric: the number of balls drawn from the urn, hence must be in 0, 1, ..., m+n

mean

integer or numeric: number of digits the mean should have

sd

integer or numeric: number of digits the standard deviation should have

norm

logical or function: normal approximation possible

pois

logical or function: poisson approximation possible

binom

logical or function: binomial approximation possible

tol

numeric: the tolerance for numerical comparison (default: '1e-6)

hyper2

logical: should the standard R parametrization ⁠(m, n, k)⁠ be used or ⁠(n+m, m, k)⁠?

Value

A data frame with possible the choices of n , p, mean and sd.

Examples

hyper_param(7:14, 1:13, 3:10, norm=FALSE, pois=FALSE, binom=FALSE, hyper2=TRUE)

exams.forge documentation built on Aug. 21, 2025, 5:41 p.m.