It's possible to build a library that gives access to some R functions, without having to install the whole of R. The package rclmath is a wrapper that gives access to some of these functions (definitions for the "utility" functions are included but not exported, the "constants" are included in a separate file but they're read as double-floats anyway and the extra precision is lost).
The stand-alone library libRmath is not included in standard R distributions. The Windows version Rmath.dll is included in the download (taken from this page with compilation instructions); for other operating systems the library is often available as a package, and otherwise can be easily compiled as described in the R Installation and Administration manual (it is also possible to cross-compile a Win32 version in Linux).
Beta, Choose, Gamma (and related), and Bessel functions are available. A random number generator is implemented that can produce the following distributions (and also the corresponding density, quantile, and cumulative distribution functions): Normal, Uniform, Gamma, Beta, Lognormal, [Non-central] Chi-squared, [Non-central] F, [Non-central] Student's t, [Negative] Binomial, Cauchy, Exponential, Geometric, Hypergeometric, Poisson, Logistic, Weibull, Studentized Range, Wilcoxon [Signed] Rank.
R 2.7 | AllegroCL 8.1 | CLISP 2.46 | ClozureCL 1.2 | CMUCL 19e | ECL 0.9l | LispWorks 5.1 | SBCL 1.0 |
---|---|---|---|---|---|---|---|
Windows/i386 | OK | OK | NA | NA | OK | OK | OK |
Linux/i386 | OK | OK | NA | OK | OK | OK | OK |
MacOSX/i386 | OK | no FFI | [64-bit] OK | NA | FFI fails | OK | OK |
MacOSX/PPC | OK | OK | OK | OK | no DFFI | OK | OK |
Download: rclmath.tar.gz
(asdf-install:install "http://common-lisp.net/project/rcl/rclmath.tar.gz")
CL-USER> (rmath:gamma 3.2) 2.4239655953848476d0 CL-USER> (rmath:bessel :i 2 3) 0.21273995923985264d0 CL-USER> (rmath:rng-seed) (1234 5678) CL-USER> (rmath:r-weibull 2 .3) 0.4531797452688073d0 CL-USER> (rmath:r-weibull 2 .3) 0.11911193157047341d0 CL-USER> (setf (rmath:rng-seed) '(1234 5678)) (1234 5678) CL-USER> (rmath:r-weibull 2 .3) 0.4531797452688073d0
(defpackage "RCLMATH" (:nicknames "RMATH") (:use "CL") (:export "RANDOM-NORMAL" "RANDOM-UNIFORM" "RANDOM-EXPONENTIAL" "RNG-SEED" "BESSEL" "BETA" "CHOOSE" "GAMMA" "PSI" "R-NORM" "D-NORM" "P-NORM" "Q-NORM" "R-UNIF" "D-UNIF" "P-UNIF" "Q-UNIF" "R-GAMMA" "D-GAMMA" "P-GAMMA" "Q-GAMMA" "R-BETA" "D-BETA" "P-BETA" "Q-BETA" "R-LNORM" "D-LNORM" "P-LNORM" "Q-LNORM" "R-CHISQ" "D-CHISQ" "P-CHISQ" "Q-CHISQ" "R-NCHISQ" "D-NCHISQ" "P-NCHISQ" "Q-NCHISQ" "R-F" "D-F" "P-F" "Q-F" "R-T" "D-T" "P-T" "Q-T" "R-BINOM" "D-BINOM" "P-BINOM" "Q-BINOM" "R-CAUCHY" "D-CAUCHY" "P-CAUCHY" "Q-CAUCHY" "R-EXP" "D-EXP" "P-EXP" "Q-EXP" "R-GEOM" "D-GEOM" "P-GEOM" "Q-GEOM" "R-HYPER" "D-HYPER" "P-HYPER" "Q-HYPER" "R-NBINOM" "D-NBINOM" "P-NBINOM" "Q-NBINOM" "R-POIS" "D-POIS" "P-POIS" "Q-POIS" "R-WEIBULL" "D-WEIBULL" "P-WEIBULL" "Q-WEIBULL" "R-LOGIS" "D-LOGIS" "P-LOGIS" "Q-LOGIS" "R-WILCOX" "D-WILCOX" "P-WILCOX" "Q-WILCOX" "R-SIGNRANK" "D-SIGNRANK" "P-SIGNRANK" "Q-SIGNRANK" "D-NBETA" "P-NBETA" "Q-NBETA" "D-NF" "P-NF" "Q-NF" "D-NT" "P-NT" "Q-NT" "P-TUKEY" "Q-TUKEY"))