Crate ruststat

Crate ruststat 

Source
Expand description

§ruststat

Utilities for working with many common random variables.

probability mass function (pmf), probability density function (pdf) cumulative distribution function (cdf) percentiles (inverse cdf) random number generation mean, variance

Distributions: Continuous: beta, chi-square, exponential, F, gamma, normal, log-normal, Pareto (1 thru 4), Student’s t, continuous uniform Discrete: binomial, geometric, hypergeometric, negative binomial, poisson

Utilities for working with many common random variables.

  • probability mass function (pmf), probability density function (pdf)
  • cumulative distribution function (cdf)
  • percentiles (inverse cdf)
  • random number generation
  • mean, variance

Distributions:

  • Continuous: beta, chi-square, exponential, F, gamma, normal, log-normal, Pareto (1 thru 4), Student’s t, continuous uniform
  • Discrete: binomial, geometric, hypergeometric, negative binomial, poisson

§Quick Start

use ruststat::*;
// X~N(mu=0,sigma=1.0), find 97.5th percentile
println!("normal percentile: {}", normal_per(0.975, 0.0, 1.0));
// X~Bin(n=10,p=0.7), compute P(X=4)
println!("binomial probability: {}", bin_pmf(4, 10, 0.7));

For convenience, functions can also be accessed via Structs.

use ruststat::*;
// X~Beta(alpha=0.5,beta=2.0)
let mut mybeta = BetaDist{alpha:0.5, beta:2.0};
// 30th percentile
println!("percentile: {}", mybeta.per(0.3));
// P(X <= 0.4)
println!("cdf: {}", mybeta.cdf(0.4));
// Random draw
println!("random draw: {}", mybeta.ran());
// Variance
println!("variance: {}", mybeta.var());

Structs§

BetaDist
Struct for the beta distribution X ~ Beta(alpha, beta).
BinDist
Struct for the binomial distirubion X ~ Bin(n,p).
ChiSqDist
Struct for the chi-square distribution X ~ ChiSq(nu).
ExpDist
Struct for the exponential distribution X ~ Exp(lambda).
FDist
Struct for the F distribution X ~ F(nu1, nu2).
GammaDist
Struct for the gamma distribution X ~ Gamma(alpha, beta).
Geo2Dist
Struct for the geometric distribution X ~ Geo(p) where X = the trial on which the first success is observed.
GeoDist
Struct for the geometric distribution X ~ Geo(p) where X = the number of failures prior to observing the first success.
GumbelDist
Struct for the Gumbel distribution X ~ Gumbel(mu, beta).
HGDist
Struct for the hypergeometric distribution X ~ HG(n,N,M).
LogNormalDist
Struct for the log-normal distribution X ~ LogNormal(mu, sigma).
NB2Dist
Struct for the negative binomial distribution X ~ NB(r,p) where X = the trial on which the rth success is observed.
NBDist
Struct for the negative binomial distribution X ~ NB(r,p) where X = the number of failures prior to observing the rth success.
NormalDist
Struct for the normal distribution X ~ Normal(mu, sigma).
Pareto1Dist
Struct for the Pareto (type I) distribution X ~ Pareto1(sigma, alpha).
Pareto2Dist
Struct for the Pareto (type II) distribution X ~ Pareto2(mu, sigma, alpha).
Pareto3Dist
Struct for the Pareto (type III) distribution X ~ Pareto3(mu, sigma, gamma).
Pareto4Dist
Struct for the Pareto (type IV) distribution X ~ Pareto4(mu, sigma, gamma, alpha).
PoisDist
Struct for the Poisson distribution X ~ Pois(lambda).
TDist
Struct for Student’s t distribution X ~ t(nu).
UnifDist
Struct for continuous uniform distribution X ~ Unif(a,b).

Functions§

beta_cdf
Computes cumulative distribution function (cdf) for X ~ Beta(alpha, beta).
beta_fn
Computes beta function.
beta_pdf
Computes probability density function (pdf) for X ~ Beta(alpha, beta).
beta_per
Computes a percentile for X ~ Beta(alpha,beta)
beta_ran
Random draw from X ~ Beta(alpha,beta) distribution.
beta_ranvec
Save random draws from X ~ Beta(alpha, beta) distribution into a Vec
betai
Incomplete beta function.
betai_inv
Inverse of incomplete beta function
bin_cdf
Computes cumulative distribution function (cdf) for X ~ Bin(n,p)
bin_per
Computes a percentile for X ~ Bin(n,p)
bin_pmf
Computes probability mass function (pmf) for X ~ Bin(n,p)
bin_ran
Random draw from X ~ Bin(n,p) distribution Sheldon Ross, Simulation, (2003)
bin_ranvec
Save random draws from X ~ Bin(n,p) distribution into a Vec
chisq_cdf
Computes cumulative distribution function (cdf) for X ~ ChiSq(nu).
chisq_pdf
Computes probability density function (pdf) for X ~ ChiSq(nu).
chisq_per
Computes a percentile for X ~ ChiSq(nu)
chisq_ran
Random draw from X ~ ChiSq(nu) distribution.
chisq_ranvec
Save random draws from X ~ ChiSq(nu) into a Vec.
comb
Combination
erf
Error function (Chebyshev implementation)
erf2
Error function (gammp implementation) Erf(x)
erf_inv
Inverse of error function
erfc
Complementary error function
erfc_inv
Inverse of complementary error function
exp_cdf
Computes cumulative distribution function (cdf) for X ~ Exp(lambda).
exp_pdf
Computes probability density function (pdf) for X ~ Exp(lambda).
exp_per
Computes a percentile for X ~ Exp(lambda)
exp_ran
Random draw from X ~ Exp(lambda) distribution.
exp_ranvec
Save random draws from X ~ Exp(lambda) into a Vec.
f_cdf
Computes cumulative distribution function (cdf) for X ~ F(nu1, nu2).
f_pdf
Computes probability density function (pdf) for X ~ F(nu1, nu2).
f_per
Computes a percentile for X ~ F(nu1, nu2).
f_ran
Random draw from X ~ F(nu1, nu2) distribution.
f_ranvec
Save random draws from X ~ F(nu1, nu2) distribution into a Vec
fact_f
Generalized factorial (f64).
fact_i
Factorial (i32).
factln_f
Log Generalized factorial (f64).
factln_i
Log factorial (i32).
gamma
Gamma function
gamma_cdf
Computes cumulative distribution function (cdf) for X ~ Gamma(alpha, beta).
gamma_pdf
Computes probability density function (pdf) for X ~ Gamma(alpha, beta).
gamma_per
Computes a percentile for X ~ Gamma(alpha, beta).
gamma_ran
Random draw from X ~ Gamma(alpha, beta) distribution.
gamma_ranvec
Save random draws from X ~ Gamma(alpha, beta) distribution into a Vec
gammai_inv
Inverse of incomplete gamma function
gammaln
Log gamma function
gammapprox
Incomplete gamma function, quadrature P(x,a)
gammp
Incomplete gamma function P(x,a)
gammq
Complmentary incomplete gamma function Q(x,a)
gcf
Incomplete gamma function, continued fraction representation
geo2_cdf
Computes cumulative distribution function (cdf) for X ~ Geo(p) where X = the trial on which the first success is observed.
geo2_per
Computes a percentile for X ~ Geo(p) where X = the trial on which the first success is observed.
geo2_pmf
Computes probability mass function (pmf) for X ~ Geo(p) where X = the trial on which the first success is observed.
geo2_ran
Random draw from X ~ Geo(p) distribution where X = the trial on which the first success is observed.
geo2_ranvec
Save random draws from X ~ Geo(p) distribution into a Vec where X = the trial on which the first success is observed.
geo_cdf
Computes cumulative distribution function (cdf) for X ~ Geo(p) where X = the number of failures prior to the first success.
geo_per
Computes a percentile for X ~ Geo(p) where X = the number of failures prior to the first success.
geo_pmf
Computes probability mass function (pmf) for X ~ Geo(p) where X = the number of failures prior to the first success.
geo_ran
Random draw from X ~ Geo(p) distribution where X = the number of failures prior to the first success.
geo_ranvec
Save random draws from X ~ Geo(p) distribution into a Vec
gser
Incomplete gamma function, series representation
gumbel_cdf
Computes cumulative distribution function (cdf) for X ~ Gumbel(mu, beta).
gumbel_pdf
Computes probability density function (pdf) for X ~ Gumbel(mu, beta).
gumbel_per
Computes a percentile for X ~ Gumbel(mu, beta).
gumbel_ran
Random draw from X ~ Gumbel(mu, beta) distribution.
gumbel_ranvec
Random Vector taken from X ~ Gumbel(mu, beta) distribution.
hg_cdf
Computes cumulative distribution function (cdf) for X ~ HG(n,N,M) where X = the number of successes.
hg_per
Computes a percentile for X ~ HG(n,N,M) where X = the number of successes.
hg_pmf
Computes probability mass function (pmf) for X ~ HG(n,N,M) where X = the number of successes.
hg_ran
Random draw from X ~ HG(n, N, M) distribution where X = the number of successes.
hg_ranvec
Save random draws from X ~ HG(n,N,M) distribution into a Vec where X = the number of successes.
lognormal_cdf
Computes cumulative distribution function (cdf) for X ~ LogNormal(mu, sigma).
lognormal_pdf
Computes probability density function (pdf) for X ~ LogNormal(mu, sigma).
lognormal_per
Computes a percentile for X ~ LogNormal(mu, sigma).
lognormal_ran
Random draw from X ~ LogNormal(mu, sig) distribution.
lognormal_ranvec
Save random draws from X ~ LogNormal(mu, sigma) distribution into a Vec
nb2_cdf
Computes cumulative distribution function (cdf) for X ~ NB(r,p) where X = the trial on which the rth success is observed.
nb2_per
Computes a percentile for X ~ NB(r,p) where X = the trial on which the rth success is observed.
nb2_pmf
Computes probability mass function (pmf) for X ~ NB(r,p) where X = the trial on which the rth success is observed.
nb2_ran
Random draw from X ~ NB(r, p) distribution where X = the trial on which the rth success is observed.
nb2_ranvec
Save random draws from X ~ NB(r,p) distribution into a Vec where X = the trial on which the rth success is observed.
nb_cdf
Computes cumulative distribution function (cdf) for X ~ NB(r,p) where X = the number of failures prior to the rth success.
nb_per
Computes a percentile for X ~ NB(r,p) where X = the number of failures prior to the rth success.
nb_pmf
Computes probability mass function (pmf) for X ~ NB(r,p) where X = the number of failures prior to the rth success.
nb_ran
Random draw from X ~ NB(r, p) distribution where X = the number of failures prior to the rth success.
nb_ranvec
Save random draws from X ~ NB(r,p) distribution into a Vec where X = the number of failures prior to the rth success.
normal_cdf
Computes cumulative distribution function (cdf) for X ~ Normal(mu, sigma).
normal_pdf
Computes probability density function (pdf) for X ~ Normal(mu, sigma).
normal_per
Computes a percentile for X ~ Normal(mu, sigma).
normal_ran
Random draw from X ~ Normal(mu, sigma) distribution.
normal_ranvec
Save random draws from X ~ Normal(mu, sigma) distribution into a Vec
pareto4_cdf
Computes cumulative distribution function (cdf) for X ~ Pareto(mu, sigma, gamma, alpha).
pareto4_pdf
Computes probability density function (pdf) for X ~ Pareto(mu, sigma, gamma, alpha).
pareto4_per
Computes a percentile for X ~ Pareto(mu, sigma, gamma, alpha).
pareto4_ran
Random draw from X ~ Pareto(mu, sigma, gamma, alpha) distribution.
pareto4_ranvec
Save random draws from X ~ Pareto(mu, sigma, gamma, alpha) distribution into a Vec
pois_cdf
Computes cumulative distriubtion function (cdf) for X ~ Pois(lambda).
pois_per
Computes a percentile for X ~ Pois(lambda).
pois_pmf
Computes probability mass function (pmf) for X ~ Pois(lambda).
pois_ran
Random draw from X ~ Pois(r, p) distribution. Sheldon Ross, Simulation, 2003
pois_ranvec
Save random draws from X ~ Pois(lambda) distribution into a Vec
sample_mean
Computes sample mean of elements in a Vec
sample_sd
Computes sample standard deviation of elements in a Vec
sample_var
Computes sample variance of elements in a Vec
t_cdf
Computes cumulative distribution function (cdf) for X ~ t(nu).
t_pdf
Computes probability density function (pdf) for X ~ t(nu).
t_per
Computes a percentile for X ~ t(nu).
t_ran
Random draw from X ~ t(nu) distribution.
t_ranvec
Save random draws from X ~ t(nu) distribution into a Vec
unif_cdf
Computes cumulative distribution function (cdf) for X ~ Unif(a,b).
unif_pdf
Computes probability density function (pdf) for X ~ Unif(a,b).
unif_per
Computes a percentile for X ~ Unif(a,b).
unif_ran
Random draw from X ~ Unif(a,b) distribution.
unif_ranvec
Save random draws from X ~ Unif(a,b) distribution into a Vec