SecretarySampler: Create a streamer for the modified secretary problem based on...

Description Format Methods Examples

Description

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

Format

An R6Class generator object

Methods

Public methods


Method new()

Creates a new SecretarySampler streamer object.

Usage
SecretarySampler$new(N, c = 0, distr)
Arguments
N

the maximum number of candidates to consider

c

the cost of observing one candidate

distr

list specifying the distribution of candidate scores

Returns

The new SecretarySampler (invisibly)

Examples
distr <- list(func = "exp", "rate" = 1)
secretary <- SecretarySampler$new(N = 10, c = 0, distr = distr)


Method update()

Update the SecretarySampler streamer object.

Usage
SecretarySampler$update(x)
Arguments
x

a single observed score of a candidate

Returns

The updated SecretarySampler (invisibly)

Examples
secretary$update(2.5)


Method clone()

The objects of this class are cloneable with this method.

Usage
SecretarySampler$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

 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)

THargreaves/onlineoceanarium documentation built on Jan. 13, 2022, 10:41 p.m.