Generates a data frame with potential values for size and prob,
and is subjected to specific conditions:
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 size * prob must be one of the valid means.
The same rules applies to sd.
The parameters norm and pois can take on values of NA, TRUE, FALSE,
or be defined as a function in the format: function(size, prob).
These values determine which (size, prob) combinations are eligible:
For NA, all combinations of (size, prob) are acceptable.
If specified as a function, only those combinations for which the function returns TRUE are considered valid.
If set to TRUE, combinations are accepted only if they satisfy either the condition size * prob * (1 - prob) > 9
(for norm, indicating a normal distribution approximation), or the conditions prob < 0.05 and n > 10
(for pois, implying a Poisson 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.
binom_param(n, p, mean = NA, sd = NA, norm = NA, pois = NA, tol = 1e-06)a data frame with possible choices of n , p, mean and sd
integer: vector number of observations
numeric: vector of probabilities
integer or numeric: number of digits the mean should have
integer or numeric: number of digits the standard deviation should have
logical or function: normal approximation possible
logical or function: poisson approximation possible
numeric: the tolerance for numerical comparison (default: `1e-6)
binom_param(1000:50000, (5:25)/100, 0, 0)
Run the code above in your browser using DataLab