## THIS SOURCE FILE WILL CONTAIN CODE ASSOCIATED WITH TETSING THE INTERSECTING
## POINT METHODS.
#' Search for all intersecting points on [-1,1]
#'
#' @param f1 A function.
#' @param f2 A function.
#' @param n The number of subintervals to search for a root in.
#'
#' @export
#'
intersections <- function(f1,f2,n = 100){
rootSolve::uniroot.all(function(x) f1(x) - f2(x),interval = c(-1,1), n = n)
}
#' Compute Intersection Based Partition
#'
#' @param f1 An arm's estimated mean-reward function.
#' @param f2 An arm's estimated mean-reward function.
#' @param n The number of subintervals to search for a root in.
#'
#' @export
#'
intersect_partition <- function(f1,f2,n = 100){
points <- c(-1,intersections(f1,f2,n),1)
k <- length(points)
part <- c()
for(i in 2:k){
part <- rbind(part,c(points[i - 1], points[i]))
}
return(part)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.