Skip to content

SML library for the Rmath library, with seven SML implementations/dialects

Notifications You must be signed in to change notification settings

mclements/sml-rmath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sml-rmath: SML foreign function interface library for the Rmath library with implementations in MLton, Poly/ML, Moscow ML (MosML), MLkit, SML/NJ, SML# and Manticore

Summary

This library provides an interface to the Rmath library for a number of SML implementations/dialects, including MLton, Poly/ML, Moscow ML, MLkit, SML/NJ, SML# and Manticore.

The SML signature is given below.

Feedback is more than welcome!

Installation

Aside from the SML implementations, this library also requires the Rmath library and m4, which is used to generate code. The package was developed on Ubuntu 16.04 (64 bit) and Ubuntu 18.04 (32 bit): to install the Rmath library on Ubuntu, use apt install r-mathlib. The default make task describes some of the other tasks. Test tasks include:

test-mlton
MLton compiler (32 bit, 64 bit)
test-polyml
PolyML (32 bit, 64 bit)
test-mosml
MosML compiler (32 bit, 64 bit)
test-mlkit
MLKit compiler (32 bit)
test-smlnj
SML/NJ (32 bit — pending the 64 bit release)
test-smlsharp
SML# (32 bit (untested), 64 bit)
test-manticore
Manticore compiler (64 bit)
test-all-32
All 32 bit implementations
test-all-64
All 64 bit implementations

For installation in MosML, the user may need to change the path to the headers (currently /usr/local/include/mosml).

For installation in Manticore, the initial configure command will need to be pass the LIBS variable as -lRmath (e.g. LIBS = -lRmath ./configure). Manticore does not implement some of the functions (e.g. set_seed and get_seed).

The 32 bit implementation for SML# is untested, as I was unable to compile SML# on Ubuntu 18.04 due to the requirement for llvm-3.7.

Test output

echo NOTE: see main tasks using 'make'
make
echo NOTE: tidy up
make clean 
echo NOTE: show the test code
cat test-main.sml
echo NOTE: generate code and run all of the tests
make test-all-32
NOTE: see main tasks using make
Available tasks include: test-all-32 test-all-64 test-mlton test-polyml test-mosml test-smlsharp, test-manticore test-mlkit
NOTE: tidy up
rm -f rmath-mlton rmath-mlton.sml
rm -f rmath-polyml rmath-polyml.sml
rm -f rmath-mosml.c rmath-mosml.sml librmath-mosml.so
rm -f *.o rmath-smlsharp.sml rmath-smlsharp.smi
rm -f a.out
rm -f rmath-sig.sml
rm -f rmath-manticore.pml rmath-manticore.s
rm -f rmath-mlkit.c rmath-mlkit.sml
# rm -rf smlnj
NOTE: show the test code
fun main() =
    let
	val x = Rmath.qnorm(0.975,0.0,1.0,1,0);
	val _ = print(Real.toString(x) ^"\n")
	val (x,s) = Rmath.lgammafn_sign(3.0)
	val _ = print(Real.toString(x) ^"\n")
	val prob = Array.fromList [0.1,0.2,0.7]
	val y = Rmath.rmultinom(1000,prob)
	val _ = print(Int.toString(Array.sub(y,0)) ^"\n")
	val _ = print(Int.toString(Array.sub(y,1)) ^"\n")
	val _ = print(Int.toString(Array.sub(y,2)) ^"\n")
 	val x = Rmath.poisson_test(10.0,12.0,1.0, Rmath.TwoSided)
	val _ = print(Real.toString(x) ^"\n")
	val x = Rmath.poisson_test(10.0,8.0,1.0, Rmath.TwoSided)
	val _ = print(Real.toString(x) ^"\n")
    in
	()
    end
NOTE: generate code and run all of the tests
m4   rmath-sig.sml.in > rmath-sig.sml
m4   rmath-mlton.sml.in > rmath-mlton.sml
mlton -default-ann 'allowFFI true' -link-opt '-lRmath' test-mlton.mlb
./test-mlton
1.95996398454
0.69314718056
89
212
699
0.665693785434
0.474611803353
rm test-mlton
m4   -D LIBRMATH=/usr/lib/libRmath.so rmath-polyml.sml.in > rmath-polyml.sml
poly --script test-polyml.sml
1.95996398454
0.69314718056
89
212
699
0.665693785434
0.474611803353
m4   rmath-mlkit.c.in > rmath-mlkit.c
gcc -DTAG_VALUES -DENABLE_GC -c rmath-mlkit.c -I/usr/local/include/mosml -I/usr/share/R/include -fPIC -I/usr/local/share/mlkit/include -o libRmathmlkit.a
m4   rmath-mlkit.sml.in > rmath-mlkit.sml
mlkit -gc -o test-mlkit --libdirs "." --libs "m,c,dl,Rmathmlkit,Rmath" test-mlkit.mlb
[reading source file:	rmath-sig.sml]
[reading source file:	rmath-mlkit.sml]
[wrote X86 code file:	MLB/RI_GC/rmath-mlkit.sml.s]
[wrote X86 code file:	MLB/RI_GC/base-link_objects.s]
[wrote executable file:	test-mlkit]
./test-mlkit
1.95996398454
0.69314718056
89
212
699
0.665693785434
0.474611803353
rm test-mlkit
ml-nlffigen -d smlnj -add ../smlnj-libh.sml -DMATHLIB_STANDALONE Rmath-nlffigen.h
sml @SMLquiet -m test-smlnj.cm
Standard ML of New Jersey v110.79 [built: Tue Aug  8 23:22:33 2017]
[scanning test-smlnj.cm]
[library $c/internals/c-int.cm is stable]
[scanning (test-smlnj.cm):./smlnj/nlffi-generated.cm]
[library $SMLNJ-BASIS/basis.cm is stable]
[library $SMLNJ-BASIS/(basis.cm):basis-common.cm is stable]
[library $c/memory/memory.cm is stable]
[parsing (test-smlnj.cm):./rmath-sig.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):../smlnj-libh.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):callop-7.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):fptr-rtti-7.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-df.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):callop-9.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):fptr-rtti-9.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dt.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):callop-16.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):fptr-rtti-16.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-pf.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):callop-17.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):fptr-rtti-17.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-pt.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qf.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qt.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):callop-1.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):fptr-rtti-1.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-rf.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):callop-6.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):fptr-rtti-6.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-rt.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):callop-11.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):fptr-rtti-11.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-unif_rand.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-norm_rand.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dwilcox.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qweibull.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dweibull.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-pnbinom.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-pnchisq.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-rcauchy.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-lgamma1p.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-lgammafn.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-pweibull.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-pwilcox.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-rnbinom.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-rnchisq.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-R_pow.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-cospi.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dbeta.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dgeom.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dpois.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dunif.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-fmax2.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-fmin2.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-fprec.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-fsign.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):callop-13.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):fptr-rtti-13.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-imax2.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-imin2.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-lbeta.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-pbeta.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-pgeom.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-ppois.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-punif.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qbeta.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qgeom.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qpois.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qunif.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-rbeta.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-rgeom.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-rnorm.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-rpois.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-runif.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-sinpi.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-tanpi.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):callop-8.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):fptr-rtti-8.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dnf.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dnt.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):callop-18.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):fptr-rtti-18.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-pnf.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-pnt.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qnf.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qnt.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-gammafn.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-rwilcox.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-lchoose.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qcauchy.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-rsignrank.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-choose.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dbinom.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dchisq.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dgamma.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dhyper.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dlnorm.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dlogis.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):callop-2.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):fptr-rtti-2.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-R_pow_di.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dnbeta.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dnorm4.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qsignrank.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-fround.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-ftrunc.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-trigamma.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dcauchy.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-tetragamma.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-pentagamma.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qnbinom.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qnchisq.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-exp_rand.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-log1pmx.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-logspace_add.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-logspace_sub.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-psignrank.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-beta.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dexp.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-pexp.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qexp.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-rexp.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-sign.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):callop-20.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):fptr-rtti-20.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-rmultinom.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-digamma.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dsignrank.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):callop-3.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):fptr-rtti-3.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-bessel_i.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-bessel_j.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-bessel_k.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-bessel_y.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-pbinom.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-pchisq.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-pgamma.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-phyper.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):callop-14.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):fptr-rtti-14.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-lgammafn_sign.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-plnorm.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-plogis.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-pnbeta.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-pnorm5.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-ptukey.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qbinom.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qchisq.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qgamma.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qhyper.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qlnorm.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qlogis.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qnbeta.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qnorm5.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qtukey.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-rbinom.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-rchisq.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-qwilcox.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-rgamma.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-rhyper.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-rlnorm.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-rlogis.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dnbinom.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-dnchisq.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-psigamma.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-pcauchy.sml]
[loading (test-smlnj.cm):./smlnj/(nlffi-generated.cm):f-rweibull.sml]
[loading (test-smlnj.cm):./rmath-smlnj.sml]
[loading (test-smlnj.cm):./test-smlnj.sml]
$Execute: required privileges are:
  c-int
  primitive
1.95996398454
0.69314718056
89
212
699
0.665693785434
0.474611803353

SML signature

signature RMATH =
sig
datatype test_alternative = TwoSided | Less | Greater
(* e *)
val M_E : real
(* log2(e) *)
val M_LOG2E : real
(* log10(e) *)
val M_LOG10E : real
(* ln(2) *)
val M_LN2 : real
(* ln(10) *)
val M_LN10 : real
(* pi *)
val M_PI : real
(* 2*pi *)
val M_2PI : real
(* pi/2 *)
val M_PI_2 : real
(* pi/4 *)
val M_PI_4 : real
(* 1/pi *)
val M_1_PI : real
(* 2/pi *)
val M_2_PI : real
(* 2/sqrt(pi) *)
val M_2_SQRTPI : real
(* sqrt(2) *)
val M_SQRT2 : real
(* 1/sqrt(2) *)
val M_SQRT1_2 : real
(* sqrt(3) *)
val M_SQRT_3 : real
(* sqrt(32) *)
val M_SQRT_32 : real
(* log10(2) *)
val M_LOG10_2 : real
(* sqrt(pi) *)
val M_SQRT_PI : real
(* 1/sqrt(2pi) *)
val M_1_SQRT_2PI : real
(* sqrt(2/pi) *)
val M_SQRT_2dPI : real
(* log(2*pi) *)
val M_LN_2PI : real
(* log(pi)/2 *)
val M_LN_SQRT_PI : real
(* log(2*pi)/2 *)
val M_LN_SQRT_2PI : real
(* log(pi/2)/2 *)
val M_LN_SQRT_PId2 : real
(* R_pow function. R_pow(x,y): real * real -> real *)
val R_pow : real * real -> real
(* R_pow_di function. R_pow_di(x,y): real * int -> real *)
val R_pow_di : real * int -> real
(* Normal random numbers. norm_rand() *)
val norm_rand : unit -> real
(* Uniform random numbers. unif_rand() *)
val unif_rand : unit -> real
(* Exponential random numbers. exp_rand() *)
val exp_rand : unit -> real
(* Normal cumulative density function. pnorm5(q,mean,sd,lower,log) *)
val pnorm5 : real * real * real * int * int -> real
(* Normal quantile function. qnorm5(p,mean,sd,lower,log) *)
val qnorm5 : real * real * real * int * int -> real
(* Normal probability density function. dnorm4(p,mean,sd,log) *)
val dnorm4 : real * real * real * int -> real
(* Normal random numbers. rnorm(mean,sd): real * real -> real *)
val rnorm : real * real -> real
(* Uniform cumulative density function. punif(q,min,max,lower,log) *)
val punif : real * real * real * int * int -> real
(* Uniform quantile function. qunif(p,min,max,lower,log) *)
val qunif : real * real * real * int * int -> real
(* Uniform probability density function. dunif(p,min,max,log) *)
val dunif : real * real * real * int -> real
(* Uniform random numbers. runif(min,max): real * real -> real *)
val runif : real * real -> real
(* Gamma cumulative density function. pgamma(q,shape,scale,lower,log) *)
val pgamma : real * real * real * int * int -> real
(* Gamma quantile function. qgamma(p,shape,scale,lower,log) *)
val qgamma : real * real * real * int * int -> real
(* Gamma probability density function. dgamma(p,shape,scale,log) *)
val dgamma : real * real * real * int -> real
(* Gamma random numbers. rgamma(shape,scale): real * real -> real *)
val rgamma : real * real -> real
(* Accurate log(1+x) - x (care for small x). log1pmx(x) *)
val log1pmx : real -> real
(* log(1 + exp(x)). Rf_log1pexp(x) *)
val Rf_log1pexp : real -> real
(* Accurate log(gamma(x+1)) for small x (0 < x < 0.5). lgamma1p(x) *)
val lgamma1p : real -> real
(* log (exp (logx) + exp (logy)). logspace_add(logx,logy): real * real -> real *)
val logspace_add : real * real -> real
(* log (exp (logx) - exp (logy)). logspace_sub(logx,logy): real * real -> real *)
val logspace_sub : real * real -> real
(* Beta cumulative density function. pbeta(q,shape1,shape2,lower,log) *)
val pbeta : real * real * real * int * int -> real
(* Beta quantile function. qbeta(p,shape1,shape2,lower,log) *)
val qbeta : real * real * real * int * int -> real
(* Beta probability density function. dbeta(p,shape1,shape2,log) *)
val dbeta : real * real * real * int -> real
(* Beta random numbers. rbeta(shape1,shape2): real * real -> real *)
val rbeta : real * real -> real
(* Log-normal cumulative density function. plnorm(q,meanlog,sdlog,lower,log) *)
val plnorm : real * real * real * int * int -> real
(* Log-normal quantile function. qlnorm(p,meanlog,sdlog,lower,log) *)
val qlnorm : real * real * real * int * int -> real
(* Log-normal probability density function. dlnorm(p,meanlog,sdlog,log) *)
val dlnorm : real * real * real * int -> real
(* Log-normal random numbers. rlnorm(meanlog,sdlog): real * real -> real *)
val rlnorm : real * real -> real
(* Chi-squared cumulative density function. pchisq(q,df,lower,log) *)
val pchisq : real * real * int * int -> real
(* Chi-squared quantile function. qchisq(p,df,lower,log) *)
val qchisq : real * real * int * int -> real
(* Chi-squared probability density function. dchisq(p,df,log) *)
val dchisq : real * real * int -> real
(* Chi-squared random numbers. rchisq(df) *)
val rchisq : real -> real
(* Non-central chi-squared cumulative density function. pnchisq(q,df,ncp,lower,log) *)
val pnchisq : real * real * real * int * int -> real
(* Non-central chi-squared quantile function. qnchisq(p,df,ncp,lower,log) *)
val qnchisq : real * real * real * int * int -> real
(* Non-central chi-squared probability density function. dnchisq(p,df,ncp,log) *)
val dnchisq : real * real * real * int -> real
(* Non-central chi-squared random numbers. rnchisq(df,ncp): real * real -> real *)
val rnchisq : real * real -> real
(* F cumulative density function. pf(q,df1,df2,lower,log) *)
val pf : real * real * real * int * int -> real
(* F quantile function. qf(p,df1,df2,lower,log) *)
val qf : real * real * real * int * int -> real
(* F probability density function. df(p,df1,df2,log) *)
val df : real * real * real * int -> real
(* F random numbers. rf(df1,df2): real * real -> real *)
val rf : real * real -> real
(* T cumulative density function. pt(q,df,lower,log) *)
val pt : real * real * int * int -> real
(* T quantile function. qt(p,df,lower,log) *)
val qt : real * real * int * int -> real
(* T probability density function. dt(p,df,log) *)
val dt : real * real * int -> real
(* T random numbers. rt(df) *)
val rt : real -> real
(* Binomial cumulative density function. pbinom(q,size,prob,lower,log) *)
val pbinom : real * real * real * int * int -> real
(* Binomial quantile function. qbinom(p,size,prob,lower,log) *)
val qbinom : real * real * real * int * int -> real
(* Binomial probability density function. dbinom(p,size,prob,log) *)
val dbinom : real * real * real * int -> real
(* Binomial random numbers. rbinom(size,prob): real * real -> real *)
val rbinom : real * real -> real
(* Cauchy cumulative density function. pcauchy(q,location,scale,lower,log) *)
val pcauchy : real * real * real * int * int -> real
(* Cauchy quantile function. qcauchy(p,location,scale,lower,log) *)
val qcauchy : real * real * real * int * int -> real
(* Cauchy probability density function. dcauchy(p,location,scale,log) *)
val dcauchy : real * real * real * int -> real
(* Cauchy random numbers. rcauchy(location,scale): real * real -> real *)
val rcauchy : real * real -> real
(* Exponential cumulative density function. pexp(q,rate,lower,log) *)
val pexp : real * real * int * int -> real
(* Exponential quantile function. qexp(p,rate,lower,log) *)
val qexp : real * real * int * int -> real
(* Exponential probability density function. dexp(p,rate,log) *)
val dexp : real * real * int -> real
(* Exponential random numbers. rexp(rate) *)
val rexp : real -> real
(* Geometric cumulative density function. pgeom(q,prob,lower,log) *)
val pgeom : real * real * int * int -> real
(* Geometric quantile function. qgeom(p,prob,lower,log) *)
val qgeom : real * real * int * int -> real
(* Geometric probability density function. dgeom(p,prob,log) *)
val dgeom : real * real * int -> real
(* Geometric random numbers. rgeom(prob) *)
val rgeom : real -> real
(* Hypergeometric cumulative density function. phyper(q,m,n,k,lower,log) *)
val phyper : real * real * real * real * int * int -> real
(* Hypergeometric quantile function. qhyper(p,m,n,k,lower,log) *)
val qhyper : real * real * real * real * int * int -> real
(* Hypergeometric probability density function. dhyper(p,m,n,k,log) *)
val dhyper : real * real * real * real * int -> real
(* Hypergeometric random numbers. rhyper(m,n,k) *)
val rhyper : real * real * real -> real
(* Negative Binomial cumulative density function. pnbinom(q,size,prob,lower,log) *)
val pnbinom : real * real * real * int * int -> real
(* Negative Binomial quantile function. qnbinom(p,size,prob,lower,log) *)
val qnbinom : real * real * real * int * int -> real
(* Negative Binomial probability density function. dnbinom(p,size,prob,log) *)
val dnbinom : real * real * real * int -> real
(* Negative Binomial random numbers. rnbinom(size,prob): real * real -> real *)
val rnbinom : real * real -> real
(* Poisson cumulative density function. ppois(q,lambda,lower,log) *)
val ppois : real * real * int * int -> real
(* Poisson quantile function. qpois(p,lambda,lower,log) *)
val qpois : real * real * int * int -> real
(* Poisson probability density function. dpois(p,lambda,log) *)
val dpois : real * real * int -> real
(* Poisson random numbers. rpois(lambda) *)
val rpois : real -> real
(* Weibull cumulative density function. pweibull(q,shape,scale,lower,log) *)
val pweibull : real * real * real * int * int -> real
(* Weibull quantile function. qweibull(p,shape,scale,lower,log) *)
val qweibull : real * real * real * int * int -> real
(* Weibull probability density function. dweibull(p,shape,scale,log) *)
val dweibull : real * real * real * int -> real
(* Weibull random numbers. rweibull(shape,scale): real * real -> real *)
val rweibull : real * real -> real
(* Logistic cumulative density function. plogis(q,location,scale,lower,log) *)
val plogis : real * real * real * int * int -> real
(* Logistic quantile function. qlogis(p,location,scale,lower,log) *)
val qlogis : real * real * real * int * int -> real
(* Logistic probability density function. dlogis(p,location,scale,log) *)
val dlogis : real * real * real * int -> real
(* Logistic random numbers. rlogis(location,scale): real * real -> real *)
val rlogis : real * real -> real
(* Non-central beta cumulative distribution function. pnbeta(q,shape1,shape2,ncp,lower,log) *)
val pnbeta : real * real * real * real * int * int -> real
(* Non-central beta quantile function. qnbeta(p,shape1,shape2,ncp,lower,log) *)
val qnbeta : real * real * real * real * int * int -> real
(* Non-central beta probability density function. dnbeta(x,shape1,shape2,ncp,log) *)
val dnbeta : real * real * real * real * int -> real
(* Non-central F cumulative distribution function. pnf(q,df1,df2,ncp,lower,log) *)
val pnf : real * real * real * real * int * int -> real
(* Non-central F quantile function. qnf(p,df1,df2,ncp,lower,log) *)
val qnf : real * real * real * real * int * int -> real
(* Non-central F probability density function. dnf(x,df1,df2,ncp,log) *)
val dnf : real * real * real * real * int -> real
(* Non-central Student t cumulative distribution function. pnt(q,df,ncp,lower,log) *)
val pnt : real * real * real * int * int -> real
(* Non-central Student t quantile function. qnt(p,df,ncp,lower,log) *)
val qnt : real * real * real * int * int -> real
(* Non-central Student t probability density function. dnt(x,df,ncp,log) *)
val dnt : real * real * real * int -> real
(* Studentised rangecumulative distribution function. ptukey(q,nmeans,df,nranges,lower,log) *)
val ptukey : real * real * real * real * int * int -> real
(* Studentised range quantile function. qtukey(p,nmeans,df,nranges,lower,log) *)
val qtukey : real * real * real * real * int * int -> real
(* Wilcoxon rank sum cumulative density function. pwilcox(q,m,n,lower,log) *)
val pwilcox : real * real * real * int * int -> real
(* Wilcoxon rank sum quantile function. qwilcox(p,m,n,lower,log) *)
val qwilcox : real * real * real * int * int -> real
(* Wilcoxon rank sum probability density function. dwilcox(p,m,n,log) *)
val dwilcox : real * real * real * int -> real
(* Wilcoxon rank sum random numbers. rwilcox(m,n): real * real -> real *)
val rwilcox : real * real -> real
(* Wilcoxon signed rank cumulative density function. psignrank(q,n,lower,log) *)
val psignrank : real * real * int * int -> real
(* Wilcoxon signed rank quantile function. qsignrank(p,n,lower,log) *)
val qsignrank : real * real * int * int -> real
(* Wilcoxon signed rank probability density function. dsignrank(p,n,log) *)
val dsignrank : real * real * int -> real
(* Wilcoxon signed rank random numbers. rsignrank(n) *)
val rsignrank : real -> real
(* gammafn. gammafn(x) *)
val gammafn : real -> real
(* lgammafn. lgammafn(x) *)
val lgammafn : real -> real
(* psigamma. psigamma(x,y): real * real -> real *)
val psigamma : real * real -> real
(* digamma. digamma(x) *)
val digamma : real -> real
(* trigamma. trigamma(x) *)
val trigamma : real -> real
(* tetragamma. tetragamma(x) *)
val tetragamma : real -> real
(* pentagamma. pentagamma(x) *)
val pentagamma : real -> real
(* beta. beta(x,y): real * real -> real *)
val beta : real * real -> real
(* lbeta. lbeta(x,y): real * real -> real *)
val lbeta : real * real -> real
(* choose. choose(n,k): real * real -> real *)
val choose : real * real -> real
(* lchoose. lchoose(n,k): real * real -> real *)
val lchoose : real * real -> real
(* bessel_i. bessel_i(x,nu,scaled) *)
val bessel_i : real * real * real -> real
(* bessel_j. bessel_j(x,nu): real * real -> real *)
val bessel_j : real * real -> real
(* bessel_k. bessel_k(x,nu,scaled) *)
val bessel_k : real * real * real -> real
(* bessel_y. bessel_y(x,nu): real * real -> real *)
val bessel_y : real * real -> real
(* fmax2. fmax2(x,y): real * real -> real *)
val fmax2 : real * real -> real
(* fmin2. fmin2(x,y): real * real -> real *)
val fmin2 : real * real -> real
(* sign. sign(x) *)
val sign : real -> real
(* fprec. fprec(x,y): real * real -> real *)
val fprec : real * real -> real
(* fround. fround(x,y): real * real -> real *)
val fround : real * real -> real
(* fsign. fsign(x,y): real * real -> real *)
val fsign : real * real -> real
(* ftrunc. ftrunc(x) *)
val ftrunc : real -> real
(* cospi. cospi(x) *)
val cospi : real -> real
(* sinpi. sinpi(x) *)
val sinpi : real -> real
(* tanpi. tanpi(x) *)
val tanpi : real -> real
(* imax2. imax2(a,b) *)
val imax2 : int * int -> int
(* imin2. imin2(a,b) *)
val imin2 : int * int -> int
(* log(1 + exp(x)). log1pexp(x) *)
val log1pexp : real -> real
(* Normal cumulative density function. pnorm(q,mean,sd,lower,log) *)
val pnorm : real * real * real * int * int -> real
(* Normal quantile function. qnorm(p,mean,sd,lower,log) *)
val qnorm : real * real * real * int * int -> real
(* Normal probability density function. dnorm(p,mean,sd,log) *)
val dnorm : real * real * real * int -> real
(* Get random seed. get_seed(a,b) *)
val get_seed : unit -> int * int
(* Set random seed. set_seed(a,b) *)
val set_seed : int * int -> unit
(* Sample from a multinomial distribution. rmultinom(n,prob) *)
val rmultinom : int * real Array.array -> int Array.array
(* log(gamma) with sign. lgammafn_sign(x) *)
val lgammafn_sign : real -> real * int
(* some additional functions *)
(* Poisson confidence interval. poisson_ci(x, t, alternative, confLevel) *)
val poisson_ci : real * real * test_alternative -> real * real
(* Poisson test. poisson_test(x, t, r, alternative) *)
val poisson_test : real * real * real * test_alternative -> real
end

About

SML library for the Rmath library, with seven SML implementations/dialects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published