Expand description
Things I’ve done to make R’s nmath library work
- Copied the nmath source
- Set
MATHLIB_STANDALONE
: telling nmath to build for use outside R - Copied R’s includes since they are still needed even with
MATHLIB_STANDALONE
. - Copy
Rconfig.h
andconfig.h
from the mingw dir (normally these files would be generated, but I think the math libs use very little of them). - Copy
Rmath.h
fromRmath.h0.in
and replace the build system placeholders (there are only 2). - Manually whitelist the functions to include, otherwise we pull in a lot of stuff, including stuff outside the source tree (and also it doesn’t compile for some reason).
Rmath.h
wierdly sets the normal functions as aliases - we have to use the raw function name here e.g.dnorm4
.
I’ve done some work on rust versions of these functions in the riir
branch. This branch
should be used for testing those functions in future.
R is released as GPLv2 which I interpret as meaning this library must also be released as GPLv2. If all the functions were replaced with native rust ones, then the license could be changed to something more permissive.
Modules§
- ffi
- This module provides the output of bindgen, in case the raw functions are useful.
Functions§
- beta_
cdf - Evaluate the culmulative distribution function of the beta distribution with parameters
a
andb
atx
. - beta_
pdf - Evaluate the probability density function of the beta distribution with parameters
a
andb
atx
. - beta_
quantile - Evaluate the quantile function of the beta distribution with parameters
a
andb
at probabilityp
. - binomial_
cdf - Evaluate the culmulative distribution function of the binomial distribution with
n
trials and probability of successp
atx
. - binomial_
pdf - Evaluate the probability density function of the binomial distribution with
n
trials and probability of successp
atx
. - binomial_
quantile - Evaluate the quantile function of the binomial distribution with
n
trials and probability of successpr
at probabilityp
. - cauchy_
cdf - Evaluate the culmulative distribution function of the Cauchy distribution with parameters
location
andscale
atx
. - cauchy_
pdf - Evaluate the probability density function of the Cauchy distribution with parameters
location
andscale
atx
. - cauchy_
quantile - Evaluate the quantile function of the Cauchy distribution with parameters
location
andscale
at probabilityp
. - chi_
squared_ cdf - Evaluate the culmulative distribution function of the chi-squared distribution with
df
degrees of freedom atx
. - chi_
squared_ pdf - Evaluate the probability density function of the chi-squared distribution with
df
degrees of freedom atx
. - chi_
squared_ quantile - Evaluate the quantile function of the chi-squared distribution with
df
degrees of freedom at probabilityp
. - exponential_
cdf - Evaluate the culmulative distribution function of the exponential distribution with given
scale
atx
. - exponential_
pdf - Evaluate the probability density function of the exponential distribution with given
scale
atx
. - exponential_
quantile - Evaluate the quantile function of the exponential distribution with given
scale
at probabilityp
. - f_cdf
- Evaluate the culmulative distribution function of the f distribution with parameters
df1
anddf2
atx
. - f_pdf
- Evaluate the probability density function of the f distribution with parameters
df1
anddf2
atx
. TODO I think df1 is the numerator degrees of freedom (when viewed as the ratio of two chi-squared dists. Check and doc this. - f_
quantile - Evaluate the quantile function of the f distribution with parameters
df1
anddf2
at probabilityp
. - gamma_
cdf - Evaluate the culmulative density function of the gamma distribution with
shape
andscale
atx
. - gamma_
pdf - Evaluate the probability density function of the gamma distribution with given
shape
andscale
atx
. - gamma_
quantile - Evaluate the quantile function of the gamma distribution with
shape
andscale
at probabilityp
. - geometric_
cdf - Evaluate the culmulative distribution function of the geometric distribution with trial
probability
p
atx
.P(X=x) = p(1-p)^x
. - geometric_
pdf - Evaluate the probability density function of the geometric distribution with trial probability
p
atx
.P(X=x) = p(1-p)^x
. - geometric_
quantile - Evaluate the quantile function of the geometric distribution with trial probability
prob
at probabilityp
.P(X=x) = p(1-p)^x
. - hypergeometric_
cdf - Evaluate the culmulative distribution function of the hypergeometric distribution. If
samples
samples were taken at random from a collection ofsucc
successes andfail
failures, then this function evaluates the chance of≤x
successes being in the sample. - hypergeometric_
pdf - Evaluate the probability density function of the hypergeometric distribution. If
samples
samples were taken at random from a collection ofsucc
successes andfail
failures, then this function evaluates the chance ofx
successes being in the sample. - hypergeometric_
quantile - Evaluate the quantile function of the hypergeometric distribution. If
samples
samples were taken at random from a collection ofsucc
successes andfail
failures, then this function evaluates the number of samples where there isp
probability there are <= that many successes. - logistic_
cdf - Evaluate the culmulative distribution function of the logistic distribution.
- logistic_
pdf - Evaluate the probability density function of the logistic distribution.
- logistic_
quantile - Evaluate the quantile function of the logistic distribution.
- lognormal_
cdf - Evaluate the culmulative distribution function of the log-normal distribution with parameters
mean_log
andsd_log
atx
. - lognormal_
pdf - Evaluate the probability density function of the log-normal distribution with parameters
mean_log
andsd_log
atx
. - lognormal_
quantile - Evaluate the quantile function of the log-normal distribution with parameters
mean_log
andsd_log
at probabilityp
. - neg_
binomial_ cdf - Evaluate the culmulative distribution function of the negative binomial distribution. If there
is
prob
probability of successin a Bernoulli trial, and we perform trials until we seesize
successes, then this function returns the probability of seeing≤x
failures in those trials. - neg_
binomial_ pdf - Evaluate the probability density function of the negative binomial distribution. If there is
prob
probability of successin a Bernoulli trial, and we perform trials until we seesize
successes, then this function returns the probability of seeingx
failures in those trials. - neg_
binomial_ quantile - Evaluate the quantile function of the negative binomial distribution. If there
is
prob
probability of successin a Bernoulli trial, and we perform trials until we seesize
successes, then this function returns the number of failures we would expect to see with probabilityp
. - non_
central_ beta_ cdf - Evaluate the culmulative distribution function of the non-central beta distribution.
- non_
central_ beta_ pdf - Evaluate the probability density function of the non-central beta distribution.
- non_
central_ beta_ quantile - Evaluate the quantile function of the non-central beta distribution.
- non_
central_ f_ cdf - Evaluate the culmulative distribution function of the non-central f distribution.
- non_
central_ f_ pdf - Evaluate the probability density function of the non-central f distribution.
- non_
central_ f_ quantile - Evaluate the quantile function of the non-central f distribution.
- non_
central_ t_ cdf - Evaluate the culmulative distribution function of the non-central student’s t distribution.
- non_
central_ t_ pdf - Evaluate the probability density function of the non-central student’s t distribution.
- non_
central_ t_ quantile - Evaluate the quantile function of the non-central student’s t distribution.
- noncentral_
chi_ squared_ cdf - Evaluate the culmulative distribution function of the non-central chi-squared distribution with
df
degrees of freedom and non-centrality parameterncp
atx
. - noncentral_
chi_ squared_ pdf - Evaluate the probability density function of the non-central chi-squared distribution with
df
degrees of freedom and non-centrality parameterncp
atx
. - noncentral_
chi_ squared_ quantile - Evaluate the quantile function of the non-central chi-squared distribution with
df
degrees of freedom and non-centrality parameterncp
at probabilityp
. - normal_
cdf - Evaluate the culmulative density function of the normal distribution with mean
mu
and variancesigma
squared atx
. - normal_
cdf_ both - Evaluate the culmulative density function of the normal distribution with mean
mu
and variancesigma
atx
. Both integrals ((-∞, x)
and(x, ∞)
) are returned in that order. - normal_
pdf - Evaluate the probability density function of the normal distribution with mean
mu
and variancesigma
2 atx
. - normal_
quantile - Evaluate the quantile function of the normal distribution with mean
mu
and variancesigma
squared at probabilityp
. - poisson_
cdf - Evaluate the culmulative distribution function of the poisson distribution.
- poisson_
pdf - Evaluate the probability density function of the poisson distribution.
- poisson_
quantile - Evaluate the quantile function of the poisson distribution.
- signrank_
cdf - Evaluate the culmulative distribution function of the signrankon signed rank distribution.
- signrank_
pdf - Evaluate the probability density function of the Wilcoxon signed rank distribution.
- signrank_
quantile - Evaluate the quantile function of the signrankon signed rank distribution.
- students_
t_ cdf - Evaluate the culmulative distribution function of the student’s t distribution with degrees of
freedom
df
atx
. - students_
t_ pdf - Evaluate the probability density function of the student’s t distribution with degrees of
freedom
df
atx
. - students_
t_ quantile - Evaluate the quantile function of the student’s t distribution with degrees of
freedom
df
at probabilityp
. - tukey_
pdf - Evaluate the culmulative distribution function of the studentized range distribution.
- tukey_
quantile - Evaluate the quantile function of the studentized range distribution.
- weibull_
cdf - Evaluate the culmulative distribution function of the Weibull distribution.
- weibull_
pdf - Evaluate the probability density function of the Weibull distribution.
- weibull_
quantile - Evaluate the quantile function of the Weibull distribution.
- wilcox_
cdf - Evaluate the culmulative distribution function of the Wilcoxon rank-sum distribution.
- wilcox_
pdf - Evaluate the probability density function of the Wilcoxon rank-sum distribution.
- wilcox_
quantile - Evaluate the quantile function of the Wilcoxon rank-sum distribution.