N armed bandit simulation

[This article was first published on Random Miner, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

As i learn more and more about machine learning and AI algorithms in general, i came across this book by Sutton & Barto, which is all about reinforcement learning. As i read through the action-value topic, it seemed a nice R-challenge, so here’s the complete code:

To test one greedy player and two epsilon players, for example, just run

 do.simulation(N = 500, plays = 1000, eps = c(0, 0.01, 0.1)) 

A quick explanation of some key parameters:

  • N: the number of replications for each simulation
  • plays: the number of moves for each player
  • eps: the probability of make a exploratory (random) move, for each player

That’s it, any comments or improvements are welcome, enjoy it!

To leave a comment for the author, please follow the link and comment on their blog: Random Miner.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)