This repository comprises of Nim bindings to libRmath, a local fork of libRmath patched by the Julia developers to use a faster random number generator.
This is currently a work in progress, and while the low-level wrapper is mostly complete, the high level wrappers have yet to be written.
git clone http://github.com/sdwfrost/libRmath-nim.git
cd libRmath-nim
make
You will need to ensure that the shared library (libRmath-nim.dylib, libRmath-nim.so, or Rmath-nim.dll) can be found (e.g. by setting LD_LIBRARY_PATH
).
The package can be installed using nimble.
git clone http://github.com/sdwfrost/rmath.git
cd rmath
nimble install
import random
import rmath
randomize()
set_seed(random(2500),random(2500))
var x=unif_rand()
echo x
var z=norm_rand()
echo z
var y=pchisq(3.84,1,true,false)
echo y
cd test
nim c --app:console -d:release --run test.nim
The above should give something like the following.
0.4356026948512537
-0.1727166441552057
0.9499564787512947
- Generate wrappers that convert types.
- Implement higher level wrappers modelled from Julia's Distributions.jl package.