Description Format Methods Examples
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)
Nthe maximum number of candidates to consider
cthe cost of observing one candidate
distrlist specifying the distribution of candidate scores
The new SecretarySampler (invisibly)
distr <- list(func = "exp", "rate" = 1) secretary <- SecretarySampler$new(N = 10, c = 0, distr = distr)
update()Update the SecretarySampler streamer object.
SecretarySampler$update(x)
xa single observed score of a candidate
The updated SecretarySampler (invisibly)
secretary$update(2.5)
clone()The objects of this class are cloneable with this method.
SecretarySampler$clone(deep = FALSE)
deepWhether to make a deep clone.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 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
## ------------------------------------------------
## 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.