Dirk Eddelbuettel — written Dec 18, 2012 — source
R, as a statistical language and environment, has very well written and
tested statistical distribution functions providing probability density,
cumulative distribution, quantiles and random number draws for dozens of
common and not so common distribution functions. This code is used inside
R, and available for use from standalone C or C++ programs via the
standalone R math library which Debian / Ubuntu have as a package
(and which can be built from R sources).
The short example below shows this for a simple function taking a vector,
and returning its pnorm computed using the R
We can now use the function to compute the probability distribution:
 0.5000 0.5004 0.5008 0.5012 0.5016 0.5020
Note that the C++ code, through its use via Rcpp attributes, will be augmented with
an automatic instantiation of a
RNGScope object which ensures a proper state
of the R random number generator.