SecretarySampler.Rd
SecretarySampler
creates a streamer object to reject
or accept a candidate based on their score. The assumptions of the process
are as follows:
- we are allowed to make at most N successive draws from a hypothetical
population of candidates with a known distribution function of scores
- we are allowed to stop at the end of any draw and we gain the score of
the currently observed candidate minus the total cost of observing
all previous candidates
- if we decide to continue sampling, it is not possible to go back to
a previous candidate
- if we decide to stop or reach the last candidate, the process ends.
Implementation is based on doi:10.1016/0022-247X(61)90023-3
An R6Class
generator object
new()
Creates a new SecretarySampler
streamer object.
SecretarySampler$new(N, c = 0, distr)
N
the maximum number of candidates to consider
c
the cost of observing one candidate
distr
list specifying the distribution of candidate scores
distr <- list(func = "exp", "rate" = 1)
secretary <- SecretarySampler$new(N = 10, c = 0, distr = distr)
update()
Update the SecretarySampler
streamer object.
set.seed(0)
candidate_scores <- rexp(10, rate = 1)
distr = list(func = "exp", rate = 1)
secretary <- SecretarySampler$new(10, c = 0, distr = distr)
i <- 1
while(secretary$value$state == "CONTINUE"
&& i <= length(candidate_scores)) {
secretary$update(candidate_scores[i])
i <- i + 1
}
secretary$value
#> $state
#> [1] "STOP"
#>
#> $score
#> [1] 2.894969
#>
#> $n_observed
#> [1] 5
#>
#> $total_cost
#> [1] 0
#>
#> $critical_values
#> [1] 1.000000 1.367879 1.622526 1.819925 1.981963 2.119762 2.239822 2.346299
#> [9] 2.442022 2.529007
#>
## ------------------------------------------------
## Method `SecretarySampler$new`
## ------------------------------------------------
distr <- list(func = "exp", "rate" = 1)
secretary <- SecretarySampler$new(N = 10, c = 0, distr = distr)
## ------------------------------------------------
## Method `SecretarySampler$update`
## ------------------------------------------------
secretary$update(2.5)