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§
- Beta
Dist - Struct for the beta distribution
X ~ Beta(alpha, beta)
. - BinDist
- Struct for the binomial distirubion
X ~ Bin(n,p)
. - ChiSq
Dist - 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)
. - Gamma
Dist - Struct for the gamma distribution
X ~ Gamma(alpha, beta)
. - Geo2
Dist - Struct for the geometric distribution
X ~ Geo(p)
whereX =
the trial on which the first success is observed. - GeoDist
- Struct for the geometric distribution
X ~ Geo(p)
whereX =
the number of failures prior to observing the first success. - Gumbel
Dist - Struct for the Gumbel distribution
X ~ Gumbel(mu, beta)
. - HGDist
- Struct for the hypergeometric distribution
X ~ HG(n,N,M)
. - LogNormal
Dist - Struct for the log-normal distribution
X ~ LogNormal(mu, sigma)
. - NB2Dist
- Struct for the negative binomial distribution
X ~ NB(r,p)
whereX =
the trial on which ther
th success is observed. - NBDist
- Struct for the negative binomial distribution
X ~ NB(r,p)
whereX =
the number of failures prior to observing ther
th success. - Normal
Dist - Struct for the normal distribution
X ~ Normal(mu, sigma)
. - Pareto1
Dist - Struct for the Pareto (type I) distribution
X ~ Pareto1(sigma, alpha)
. - Pareto2
Dist - Struct for the Pareto (type II) distribution
X ~ Pareto2(mu, sigma, alpha)
. - Pareto3
Dist - Struct for the Pareto (type III) distribution
X ~ Pareto3(mu, sigma, gamma)
. - Pareto4
Dist - Struct for the Pareto (type IV) distribution
X ~ Pareto4(mu, sigma, gamma, alpha)
. - Pois
Dist - Struct for the Poisson distribution
X ~ Pois(lambda)
. - TDist
- Struct for Student’s t distribution
X ~ t(nu)
. - Unif
Dist - 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 aVec
- 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 aVec
- 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 aVec
. - 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 aVec
. - 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 aVec
- 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 aVec
- 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)
whereX =
the trial on which the first success is observed. - geo2_
per - Computes a percentile for
X ~ Geo(p)
whereX =
the trial on which the first success is observed. - geo2_
pmf - Computes probability mass function (pmf) for
X ~ Geo(p)
whereX =
the trial on which the first success is observed. - geo2_
ran - Random draw from
X ~ Geo(p)
distribution whereX =
the trial on which the first success is observed. - geo2_
ranvec - Save random draws from
X ~ Geo(p)
distribution into aVec
whereX =
the trial on which the first success is observed. - geo_cdf
- Computes cumulative distribution function (cdf) for
X ~ Geo(p)
whereX =
the number of failures prior to the first success. - geo_per
- Computes a percentile for
X ~ Geo(p)
whereX =
the number of failures prior to the first success. - geo_pmf
- Computes probability mass function (pmf) for
X ~ Geo(p)
whereX =
the number of failures prior to the first success. - geo_ran
- Random draw from
X ~ Geo(p)
distribution whereX =
the number of failures prior to the first success. - geo_
ranvec - Save random draws from
X ~ Geo(p)
distribution into aVec
- 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)
whereX =
the number of successes. - hg_per
- Computes a percentile for
X ~ HG(n,N,M)
whereX =
the number of successes. - hg_pmf
- Computes probability mass function (pmf) for
X ~ HG(n,N,M)
whereX =
the number of successes. - hg_ran
- Random draw from
X ~ HG(n, N, M)
distribution whereX =
the number of successes. - hg_
ranvec - Save random draws from
X ~ HG(n,N,M)
distribution into aVec
whereX =
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 aVec
- nb2_cdf
- Computes cumulative distribution function (cdf) for
X ~ NB(r,p)
whereX =
the trial on which ther
th success is observed. - nb2_per
- Computes a percentile for
X ~ NB(r,p)
whereX =
the trial on which ther
th success is observed. - nb2_pmf
- Computes probability mass function (pmf) for
X ~ NB(r,p)
whereX =
the trial on which ther
th success is observed. - nb2_ran
- Random draw from
X ~ NB(r, p)
distribution whereX =
the trial on which ther
th success is observed. - nb2_
ranvec - Save random draws from
X ~ NB(r,p)
distribution into aVec
whereX =
the trial on which ther
th success is observed. - nb_cdf
- Computes cumulative distribution function (cdf) for
X ~ NB(r,p)
whereX =
the number of failures prior to ther
th success. - nb_per
- Computes a percentile for
X ~ NB(r,p)
whereX =
the number of failures prior to ther
th success. - nb_pmf
- Computes probability mass function (pmf) for
X ~ NB(r,p)
whereX =
the number of failures prior to ther
th success. - nb_ran
- Random draw from
X ~ NB(r, p)
distribution whereX =
the number of failures prior to ther
th success. - nb_
ranvec - Save random draws from
X ~ NB(r,p)
distribution into aVec
whereX =
the number of failures prior to ther
th 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 aVec
- 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 aVec
- 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 aVec
- 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 aVec
- 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 aVec