Calculates the number of samples from an urn under different sampling scenarios.
Usage
nsamp(n, k, replace = FALSE, ordered = FALSE)
Arguments
n
an integer or integer vector.
k
an integer or integer vector.
replace
logical indicating whether sampling should be done with replacement.
ordered
logical indicating whether order among samples is important.
Value
A number.
Details
The nsamp() function will calculate the number of samples from an urn under assorted assumptions on the sampling procedure. The arguments are: n, the number of (distinguishable) objects in the urn, k, the sample size, and replace, ordered as documented in urnsamples.
nsamp() is vectorized, so that entering vectors instead of numbers for n, k, replace, and ordered results in a vector of corresponding answers.
The formulas used in the four possible combinations of replace and ordered are as follows.
Whenreplace = TRUEandordered = TRUE, the value is$n^k$.
Whenreplace = FALSEandordered = TRUE, the value is$n!/(n-k)!$.
Whenreplace = FALSEandordered = FALSE, the value is$n!/[k!(n-k)!]$.
Whenreplace = TRUEandordered = FALSE, the value is$(n-1+k)!/[(n-1)!k!]$.