N armed bandit simulation

August 2, 2013

(This article was first published on Random Miner, and kindly contributed to R-bloggers)

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 on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


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)