Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. # THOMPSON SAMPLING
  2. horizon <- 1000L
  3. simulations <- 1000L
  4. conversionProbabilities <- c(0.05, 0.10, 0.15, 0.20, 0.25)
  5.  
  6. bandit <- BasicBernoulliBandit$new(weights = conversionProbabilities)
  7. policy <- ThompsonSamplingPolicy$new(alpha = 1, beta = 1)
  8. agent <- Agent$new(policy, bandit)
  9.  
  10. historyThompson <- Simulator$new(agent, horizon, simulations)$run()
  11.  
  12. plot(historyThompson, type = "arms",
  13. legend_labels = c('Ad 1', 'Ad 2', 'Ad 3', 'Ad 4', 'Ad 5'),
  14. legend_title = 'Thompson Sampling',
  15. legend_position = "topright",
  16. smooth = TRUE)
  17.  
  18. summary(historyThompson)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement