0byt3m1n1
Path:
C:
/
Program Files
/
R
/
R-4.2.2
/
library
/
Rcpp
/
examples
/
Misc
/
[
Home
]
File: piSugar.cpp
#include <Rcpp.h> using namespace Rcpp; // [[Rcpp::export]] double piSugar(const int N) { NumericVector x = runif(N); NumericVector y = runif(N); NumericVector d = sqrt(x*x + y*y); return 4.0 * sum(d < 1.0) / N; }