Skip to contents

Varying number of picked options

For each colleague, the number of picked options is a number randomly drawn from a normal distribution with mean p and sd p_sd. (Note that for technical reasons, the first colleagues always picks exactly p slots currently.)

In other words, the number of p varies.

Example with non-varying p

out <- count_common_slots(n_colleagues = 3,
                          o = 7,
                          p = 3,
                          dep = .5,
                          p_sd = 0)

out
#>   slots_chosen Freq is_match
#> 1            1    3     TRUE

As can be seen, the number of picked options remains constant across all colleagues:

attr(out, "chosen_options_l")
#> [[1]]
#> [1] 3 5 1
#> 
#> [[2]]
#> [1] 5 7 1
#> 
#> [[3]]
#> [1] 3 6 1

Example with varying p

out2 <- count_common_slots(n_colleagues = 3,
                          o = 7,
                          p = 3,
                          dep = .5,
                          p_sd = 1)

out2
#>   slots_chosen Freq is_match
#> 1            2    3     TRUE
#> 2            4    3     TRUE

As can be seen, the number of picked options remains constant across all colleagues:

attr(out2, "chosen_options_l")
#> [[1]]
#> [1] 4 3 2
#> 
#> [[2]]
#> [1] 5 4 2
#> 
#> [[3]]
#> [1] 3 7 4 2

Of course, the number of picked options influences the probability of finding a match.

Sensitivity analysis 3

tic()
grid3 <- populate_grid(n_colleagues = 3:5, 
                      o = c(5, 10, 15, 20), 
                      p = c(3, 5), 
                      dep = c(0, .5),
                      p_sd = c(0, 1))
toc()
tic()
grid3a <- populate_grid(n_colleagues = 3:4, 
                      o = c(5, 10), 
                      p = c(3, 5), 
                      dep = c(0),
                      p_sd = c(0, 1))
toc()
tic()
grid3b <- populate_grid(n_colleagues = 3:5, 
                      o = c(5, 10, 15), 
                      p = c(3, 5), 
                      dep = c(0.5),
                      p_sd = c(0, 1))
toc()

It’s quicker to load from disk:

#data(grid3)

Visualize grid 3a - dep = 0

#undebug(vis_grid2)
grid3a <-
grid3 |> 
  filter(dep == 0)

vis_grid2(grid3a, facet_var_rows = "p_sd", facet_var_cols = "p")

Visualize grid 3b - dep = 0.5

#undebug(vis_grid2)
grid3b <-
grid3 |> 
  filter(dep == 0.5)
vis_grid2(grid3b, facet_var_rows = "p_sd", facet_var_cols = "p")