## There are three graphs made in each step: the top-left, one is a
## simulation of the scenario, the top-right one is to help us
## understand the connection between dropping needles and the
## mathematical method to estimate pi, and the bottom one is the result
## for each dropping.
library(animation)
par(mar = c(3, 2.5, 1, 0.2), pch = 20, mgp = c(1.5, 0.5,
0))
ani.options(nmax = ifelse(interactive(), 300, 10), interval = 0.1)
buffon.needle(type = "S", redraw = FALSE)
## R version 3.1.0 (2014-04-10)
## Platform: i386-w64-mingw32/i386 (32-bit)
## Other packages: animation 2.3