
Last chance! 50% off unlimited learning
Sale ends in
Calculates the number of samples from an urn under different sampling scenarios.
nsamp(n, k, replace = FALSE, ordered = FALSE)
an integer or integer vector.
an integer or integer vector.
logical indicating whether sampling should be done with replacement.
logical indicating whether order among samples is important.
A number.
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.
When replace = TRUE
and ordered = TRUE
, the value is
When replace = FALSE
and ordered = TRUE
, the value is
When replace = FALSE
and ordered = FALSE
, the value is
When replace = TRUE
and ordered = FALSE
, the value is
# NOT RUN {
nsamp(n=3, k=2, replace = TRUE, ordered = TRUE)
nsamp(n=3, k=2, replace = TRUE, ordered = FALSE)
nsamp(n=3, k=2, replace = FALSE, ordered = FALSE)
nsamp(n=3, k=2, replace = FALSE, ordered = TRUE)
# }
Run the code above in your browser using DataLab