Skip to content

Commit dc7e057

Browse files
committed
Add unlist() to which_max_tied()
Fixes #15 Adding "unlist" in which_max_tied
1 parent d3a9c35 commit dc7e057

File tree

7 files changed

+9
-8
lines changed

7 files changed

+9
-8
lines changed

R/bandit_basic_bernoulli.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' @export
1+
#' @export
22
BasicBernoulliBandit <- R6::R6Class(
33
inherit = Bandit,
44
class = FALSE,

R/bandit_basic_gaussian.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' @export
1+
#' @export
22
BasicGaussianBandit <- R6::R6Class(
33
inherit = Bandit,
44
class = FALSE,

R/bandit_cmab_bernoulli.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' @export
1+
#' @export
22
ContextualBernoulliBandit <- R6::R6Class(
33
inherit = Bandit,
44
class = FALSE,

R/bandit_cmab_binary.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' @export
1+
#' @export
22
ContextualBinaryBandit <- R6::R6Class(
33
inherit = Bandit,
44
class = FALSE,

R/functions_utility.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ which_max_list <- function(x, equal_is_random = TRUE) {
8787
#'
8888
#' @export
8989
which_max_tied <- function(x, equal_is_random = TRUE) {
90+
x <- unlist(x, FALSE, FALSE)
9091
x <- seq_along(x)[x == max(x)]
9192
if (length(x) > 1L && equal_is_random) {
92-
return(sample(x, 1L, replace = TRUE))
93+
return(sample(x, 1L, replace = TRUE))
9394
} else {
9495
return(x[1])
9596
}

R/policy_mab_gittins_bl.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ GittinsBrezziLaiPolicy <- R6::R6Class(
5050
p_hat <- self$theta$mean[[arm]]
5151
v_arm <- p_hat*(1 - p_hat)
5252
v_mean <- p_hat*(1 - p_hat)/(self$theta$n[[arm]] + 1)
53-
c <- - log(self$discount)
54-
self$theta$gittins_index[[arm]] <- p_hat + sqrt(v_mean) * private$phi(v_mean/(c * v_arm))
53+
cc <- - log(self$discount)
54+
self$theta$gittins_index[[arm]] <- p_hat + sqrt(v_mean) * private$phi(v_mean/(cc * v_arm))
5555
},
5656
phi = function(s) {
5757
if (s > 15) {

vignettes/only_pkgdown/faq.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ from the latter to obtain the ```regret```.
180180
For example, see ```BasicBernoulliBandit```'s implementation:
181181

182182
```r
183-
#' @export
183+
#' @export
184184
BasicBernoulliBandit <- R6::R6Class(
185185
inherit = Bandit,
186186
class = FALSE,

0 commit comments

Comments
 (0)