set.seed(123)
xx <- runif(10000,2,10)
yy <- runif(10000,2,10)
radio <- 4
plot(xx,yy, cex=0.3, xlim = c(2,10), ylim = c(2,10), asp=1, xaxt = "n", yaxt = "n")
axis(1, at = c(2, 4, 6, 8, 10))
axis(2, at = c(2, 4, 6, 8, 10))
points(6,6, cex=2, col="blue", pch=16)
count=0
for (i in 1:10000){
if (sqrt((xx[i]-6)^2 + (yy[i]-6)^2)<4){
count=count + 1
points(xx[i], yy[i], col= "green", pch=16, cex=0.3)
}
}

count
## [1] 7894
puntos <- count/length(xx)
area_cuadrado <- 8^2
area_estimada <- puntos*area_cuadrado
pi_estimado <- area_estimada/(radio^2)
data.frame(area_estimada, pi_estimado)
## area_estimada pi_estimado
## 1 50.5216 3.1576