Takes repeated samples from the population. See the Details section below for further information.
Arguments
- N
positive integer value, the population size
- p
integer, the number of elements to holdout
Value
A list of length \(\binom{N}{p}\) where each element is a vector containing the indices of the sampled data.
Details
Samples of size p
are repeatedly taken from the population until
all the possible combinations of p
elements are considered. These samples
are used as holdout data. This function returns a list of
\(\binom{N}{p} = \frac{N!}{p!(N-p)!}\)
samples of size N-p
obtained by removing the holdout samples from the
population.
Examples
#Set seed for reproducibility
set.seed(seed = 5381L)
#Repeatedly sample leaving out p elements each time
repeatedLeavePOut(N = 5, p = 2)
#> [[1]]
#> [1] 3 4 5
#>
#> [[2]]
#> [1] 2 4 5
#>
#> [[3]]
#> [1] 2 3 5
#>
#> [[4]]
#> [1] 2 3 4
#>
#> [[5]]
#> [1] 1 4 5
#>
#> [[6]]
#> [1] 1 3 5
#>
#> [[7]]
#> [1] 1 3 4
#>
#> [[8]]
#> [1] 1 2 5
#>
#> [[9]]
#> [1] 1 2 4
#>
#> [[10]]
#> [1] 1 2 3
#>
#Equivalent to leave-one-out
repeatedLeavePOut(N = 5, p = 1)
#> [[1]]
#> [1] 2 3 4 5
#>
#> [[2]]
#> [1] 1 3 4 5
#>
#> [[3]]
#> [1] 1 2 4 5
#>
#> [[4]]
#> [1] 1 2 3 5
#>
#> [[5]]
#> [1] 1 2 3 4
#>