Skip to content

Instantly share code, notes, and snippets.

@lbozhilova
lbozhilova / MCpi
Last active February 2, 2016 17:10
R code for simple Monte Carlo estimation of pi.
require (plotrix)
require (grid)
plot(c(-1, 1), c(-1,1), xlab = "x", ylab="y", type = "n", asp=1)
rect( -1, -1, 1, 1)
draw.circle( 0, 0, 1 )
N <- 150
x <- runif(N, min=-1, max=1)
y <- runif(N, min=-1, max=1)