R/calibrate_arm.R

Defines functions calibrate_arm

Documented in calibrate_arm

#' Calibrate an unknown arm against a known arm
#'
#' Performs iterative reduction of an interval using calibration with value function FUN.
#'
#' @param FUN A value function.
#' @param lb Initial lower end of interval.
#' @param ub Initial upper end of interval.
#' @param tol Absolute accuracy required.
#' @param ... Other arguments passed to `FUN`.
#'
#' @keywords internal
#' @return A vector of lower and upper end of an interval containing the true value.
#' @export
calibrate_arm <- function(FUN, lb, ub, tol, ...){
  while ((ub - lb) > tol){
    lambda <- lb + (ub - lb) / 2
    if (FUN(lambda, ...) > 0){
      lb <- lambda
    }else{
      ub <- lambda
    }
  }
  c(lb, ub)
}
jedwards24/gittins documentation built on Oct. 13, 2023, 4:17 p.m.