Crate r_mathlib

source ·
Expand description

Things I’ve done to make R’s nmath library work

  1. Copied the nmath source
  2. Set MATHLIB_STANDALONE: telling nmath to build for use outside R
  3. Copied R’s includes since they are still needed even with MATHLIB_STANDALONE.
  4. Copy Rconfig.h and config.h from the mingw dir (normally these files would be generated, but I think the math libs use very little of them).
  5. Copy Rmath.h from Rmath.h0.in and replace the build system placeholders (there are only 2).
  6. 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).
  7. 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

  • This module provides the output of bindgen, in case the raw functions are useful.

Functions

  • Evaluate the culmulative distribution function of the beta distribution with parameters a and b at x.
  • Evaluate the probability density function of the beta distribution with parameters a and b at x.
  • Evaluate the quantile function of the beta distribution with parameters a and b at probability p.
  • Evaluate the culmulative distribution function of the binomial distribution with n trials and probability of success p at x.
  • Evaluate the probability density function of the binomial distribution with n trials and probability of success p at x.
  • Evaluate the quantile function of the binomial distribution with n trials and probability of success pr at probability p.
  • Evaluate the culmulative distribution function of the Cauchy distribution with parameters location and scale at x.
  • Evaluate the probability density function of the Cauchy distribution with parameters location and scale at x.
  • Evaluate the quantile function of the Cauchy distribution with parameters location and scale at probability p.
  • Evaluate the culmulative distribution function of the chi-squared distribution with df degrees of freedom at x.
  • Evaluate the probability density function of the chi-squared distribution with df degrees of freedom at x.
  • Evaluate the quantile function of the chi-squared distribution with df degrees of freedom at probability p.
  • Evaluate the culmulative distribution function of the exponential distribution with given scale at x.
  • Evaluate the probability density function of the exponential distribution with given scale at x.
  • Evaluate the quantile function of the exponential distribution with given scale at probability p.
  • Evaluate the culmulative distribution function of the f distribution with parameters df1 and df2 at x.
  • Evaluate the probability density function of the f distribution with parameters df1 and df2 at x. TODO I think df1 is the numerator degrees of freedom (when viewed as the ratio of two chi-squared dists. Check and doc this.
  • Evaluate the quantile function of the f distribution with parameters df1 and df2 at probability p.
  • Evaluate the culmulative density function of the gamma distribution with shape and scale at x.
  • Evaluate the probability density function of the gamma distribution with given shape and scale at x.
  • Evaluate the quantile function of the gamma distribution with shape and scale at probability p.
  • Evaluate the culmulative distribution function of the geometric distribution with trial probability p at x. P(X=x) = p(1-p)^x.
  • Evaluate the probability density function of the geometric distribution with trial probability p at x. P(X=x) = p(1-p)^x.
  • Evaluate the quantile function of the geometric distribution with trial probability prob at probability p. P(X=x) = p(1-p)^x.
  • Evaluate the culmulative distribution function of the hypergeometric distribution. If samples samples were taken at random from a collection of succ successes and fail failures, then this function evaluates the chance of ≤x successes being in the sample.
  • Evaluate the probability density function of the hypergeometric distribution. If samples samples were taken at random from a collection of succ successes and fail failures, then this function evaluates the chance of x successes being in the sample.
  • Evaluate the quantile function of the hypergeometric distribution. If samples samples were taken at random from a collection of succ successes and fail failures, then this function evaluates the number of samples where there is p probability there are <= that many successes.
  • Evaluate the culmulative distribution function of the logistic distribution.
  • Evaluate the probability density function of the logistic distribution.
  • Evaluate the quantile function of the logistic distribution.
  • Evaluate the culmulative distribution function of the log-normal distribution with parameters mean_log and sd_log at x.
  • Evaluate the probability density function of the log-normal distribution with parameters mean_log and sd_log at x.
  • Evaluate the quantile function of the log-normal distribution with parameters mean_log and sd_log at probability p.
  • 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 see size successes, then this function returns the probability of seeing ≤x failures in those trials.
  • 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 see size successes, then this function returns the probability of seeing x failures in those trials.
  • 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 see size successes, then this function returns the number of failures we would expect to see with probability p.
  • Evaluate the culmulative distribution function of the non-central beta distribution.
  • Evaluate the probability density function of the non-central beta distribution.
  • Evaluate the quantile function of the non-central beta distribution.
  • Evaluate the culmulative distribution function of the non-central f distribution.
  • Evaluate the probability density function of the non-central f distribution.
  • Evaluate the quantile function of the non-central f distribution.
  • Evaluate the culmulative distribution function of the non-central student’s t distribution.
  • Evaluate the probability density function of the non-central student’s t distribution.
  • Evaluate the quantile function of the non-central student’s t distribution.
  • Evaluate the culmulative distribution function of the non-central chi-squared distribution with df degrees of freedom and non-centrality parameter ncp at x.
  • Evaluate the probability density function of the non-central chi-squared distribution with df degrees of freedom and non-centrality parameter ncp at x.
  • Evaluate the quantile function of the non-central chi-squared distribution with df degrees of freedom and non-centrality parameter ncp at probability p.
  • Evaluate the culmulative density function of the normal distribution with mean mu and variance sigma squared at x.
  • Evaluate the culmulative density function of the normal distribution with mean mu and variance sigma at x. Both integrals ((-∞, x) and (x, ∞)) are returned in that order.
  • Evaluate the probability density function of the normal distribution with mean mu and variance sigma2 at x.
  • Evaluate the quantile function of the normal distribution with mean mu and variance sigma squared at probability p.
  • Evaluate the culmulative distribution function of the poisson distribution.
  • Evaluate the probability density function of the poisson distribution.
  • Evaluate the quantile function of the poisson distribution.
  • Evaluate the culmulative distribution function of the signrankon signed rank distribution.
  • Evaluate the probability density function of the Wilcoxon signed rank distribution.
  • Evaluate the quantile function of the signrankon signed rank distribution.
  • Evaluate the culmulative distribution function of the student’s t distribution with degrees of freedom df at x.
  • Evaluate the probability density function of the student’s t distribution with degrees of freedom df at x.
  • Evaluate the quantile function of the student’s t distribution with degrees of freedom df at probability p.
  • Evaluate the culmulative distribution function of the studentized range distribution.
  • Evaluate the quantile function of the studentized range distribution.
  • Evaluate the culmulative distribution function of the Weibull distribution.
  • Evaluate the probability density function of the Weibull distribution.
  • Evaluate the quantile function of the Weibull distribution.
  • Evaluate the culmulative distribution function of the Wilcoxon rank-sum distribution.
  • Evaluate the probability density function of the Wilcoxon rank-sum distribution.
  • Evaluate the quantile function of the Wilcoxon rank-sum distribution.