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.handconfig.hfrom the mingw dir (normally these files would be generated, but I think the math libs use very little of them). - Copy
Rmath.hfromRmath.h0.inand 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.hwierdly 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
aandbatx. - beta_
pdf - Evaluate the probability density function of the beta distribution with parameters
aandbatx. - beta_
quantile - Evaluate the quantile function of the beta distribution with parameters
aandbat probabilityp. - binomial_
cdf - Evaluate the culmulative distribution function of the binomial distribution with
ntrials and probability of successpatx. - binomial_
pdf - Evaluate the probability density function of the binomial distribution with
ntrials and probability of successpatx. - binomial_
quantile - Evaluate the quantile function of the binomial distribution with
ntrials and probability of successprat probabilityp. - cauchy_
cdf - Evaluate the culmulative distribution function of the Cauchy distribution with parameters
locationandscaleatx. - cauchy_
pdf - Evaluate the probability density function of the Cauchy distribution with parameters
locationandscaleatx. - cauchy_
quantile - Evaluate the quantile function of the Cauchy distribution with parameters
locationandscaleat probabilityp. - chi_
squared_ cdf - Evaluate the culmulative distribution function of the chi-squared distribution with
dfdegrees of freedom atx. - chi_
squared_ pdf - Evaluate the probability density function of the chi-squared distribution with
dfdegrees of freedom atx. - chi_
squared_ quantile - Evaluate the quantile function of the chi-squared distribution with
dfdegrees of freedom at probabilityp. - exponential_
cdf - Evaluate the culmulative distribution function of the exponential distribution with given
scaleatx. - exponential_
pdf - Evaluate the probability density function of the exponential distribution with given
scaleatx. - exponential_
quantile - Evaluate the quantile function of the exponential distribution with given
scaleat probabilityp. - f_cdf
- Evaluate the culmulative distribution function of the f distribution with parameters
df1anddf2atx. - f_pdf
- Evaluate the probability density function of the f distribution with parameters
df1anddf2atx. 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
df1anddf2at probabilityp. - gamma_
cdf - Evaluate the culmulative density function of the gamma distribution with
shapeandscaleatx. - gamma_
pdf - Evaluate the probability density function of the gamma distribution with given
shapeandscaleatx. - gamma_
quantile - Evaluate the quantile function of the gamma distribution with
shapeandscaleat probabilityp. - geometric_
cdf - Evaluate the culmulative distribution function of the geometric distribution with trial
probability
patx.P(X=x) = p(1-p)^x. - geometric_
pdf - Evaluate the probability density function of the geometric distribution with trial probability
patx.P(X=x) = p(1-p)^x. - geometric_
quantile - Evaluate the quantile function of the geometric distribution with trial probability
probat probabilityp.P(X=x) = p(1-p)^x. - hypergeometric_
cdf - Evaluate the culmulative distribution function of the hypergeometric distribution. If
samplessamples were taken at random from a collection ofsuccsuccesses andfailfailures, then this function evaluates the chance of≤xsuccesses being in the sample. - hypergeometric_
pdf - Evaluate the probability density function of the hypergeometric distribution. If
samplessamples were taken at random from a collection ofsuccsuccesses andfailfailures, then this function evaluates the chance ofxsuccesses being in the sample. - hypergeometric_
quantile - Evaluate the quantile function of the hypergeometric distribution. If
samplessamples were taken at random from a collection ofsuccsuccesses andfailfailures, then this function evaluates the number of samples where there ispprobability 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_logandsd_logatx. - lognormal_
pdf - Evaluate the probability density function of the log-normal distribution with parameters
mean_logandsd_logatx. - lognormal_
quantile - Evaluate the quantile function of the log-normal distribution with parameters
mean_logandsd_logat probabilityp. - neg_
binomial_ cdf - Evaluate the culmulative distribution function of the negative binomial distribution. If there
is
probprobability of successin a Bernoulli trial, and we perform trials until we seesizesuccesses, then this function returns the probability of seeing≤xfailures in those trials. - neg_
binomial_ pdf - Evaluate the probability density function of the negative binomial distribution. If there is
probprobability of successin a Bernoulli trial, and we perform trials until we seesizesuccesses, then this function returns the probability of seeingxfailures in those trials. - neg_
binomial_ quantile - Evaluate the quantile function of the negative binomial distribution. If there
is
probprobability of successin a Bernoulli trial, and we perform trials until we seesizesuccesses, 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
dfdegrees of freedom and non-centrality parameterncpatx. - noncentral_
chi_ squared_ pdf - Evaluate the probability density function of the non-central chi-squared distribution with
dfdegrees of freedom and non-centrality parameterncpatx. - noncentral_
chi_ squared_ quantile - Evaluate the quantile function of the non-central chi-squared distribution with
dfdegrees of freedom and non-centrality parameterncpat probabilityp. - normal_
cdf - Evaluate the culmulative density function of the normal distribution with mean
muand variancesigmasquared atx. - normal_
cdf_ both - Evaluate the culmulative density function of the normal distribution with mean
muand variancesigmaatx. Both integrals ((-∞, x)and(x, ∞)) are returned in that order. - normal_
pdf - Evaluate the probability density function of the normal distribution with mean
muand variancesigma2 atx. - normal_
quantile - Evaluate the quantile function of the normal distribution with mean
muand variancesigmasquared 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
dfatx. - students_
t_ pdf - Evaluate the probability density function of the student’s t distribution with degrees of
freedom
dfatx. - students_
t_ quantile - Evaluate the quantile function of the student’s t distribution with degrees of
freedom
dfat 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.