Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/RcppCore/Rcpp
/ piSugar
Function
piSugar
inst/examples/Misc/piSugar.cpp:7–12 ·
view source on GitHub ↗
[[Rcpp::export]]
Source
from the content-addressed store, hash-verified
5
6
// [[Rcpp::export]]
7
double piSugar(const int N) {
8
NumericVector x = runif(N);
9
NumericVector y = runif(N);
10
NumericVector d = sqrt(x*x + y*y);
11
return 4.0 * sum(d < 1.0) / N;
12
}
Callers
nothing calls this directly
Calls
3
runif
Function · 0.50
sqrt
Function · 0.50
sum
Function · 0.50
Tested by
no test coverage detected