Distributions
distribution | parameters | support | density f(x) | mean | variance | excel function | matlab/octave | r | numpy/scipy | c++ |
---|---|---|---|---|---|---|---|---|---|---|
binomial | B(n,p) | {0,1,…,n} | $$\frac{n!}{x!(n-x)!} p^x(1-p)^{n-x}$$ | np | np(1-p) | BINOMDIST(x,n,p,FALSE) BINOMDIST(x,n,p,TRUE) BINOM.INV(n, p, α) BINOM.INV(n, p, RAND()) | binopdf(x, n, p) binocdf(x, n, p) binoinv(y, n, p) binornd(n, p) | dbinom(x, n, p) pbinom(x, n, p) qbinom(y, n, p) rbinom(1, n, p) | stats.binom.pmf(x, n, p) stats.binom.cdf(x, n, p) stats.binom.ppf(y, n, p) stats.binom.rvs(n, p) | #include <random> default_random_engine dre; binomial_distribution<int> bd(n, p); int m = bd(dre); |
poisson | Pois(λ) | {0,1,2,…} | $$\frac{\mu^x e^{-\mu}}{x!}$$ | λ | λ | POISSON(x, λ, FALSE) POISSON(x, λ, TRUE) none none | poisspdf(x, lambda) poisscdf(x, lambda) poissinv(y, lambda) poissrnd(lambda) | dpois(x, lambda) ppois(x, lambda) qpois(y, lambda) rpois(1, lambda) | stats.poisson.pmf(x, lambda) stats.poisson.cdf(x, lambda) stats.poisson.ppf(y, lambda) stats.poisson.rvs(lambda, size=1) | #include <random> default_random_engine dre; poisson_distribution<int> pd(lambda); int m = pd(dre); |
normal | N(μ, σ) | (-∞,∞) | $$\frac{1}{\sqrt{2\pi \sigma}} e^{-\frac{(x-\mu)^2}{2\sigma^2}}$$ | μ | σ2 | NORMDIST(x, μ, σ, FALSE) NORMDIST(x, μ, σ, TRUE) NORMINV(α, μ, σ) NORMINV(RAND(), μ, σ) | normpdf(x, mu, sigma) normcdf(x, mu, sigma) norminv(y, mu, sigma) normrnd(mu, sigma) | dnorm(x, mu, sigma) pnorm(x, mu, sigma) qnorm(y, mu, sigma) rnorm(1, mu, sigma) | stats.norm.pdf(x, mu, sigma) stats.norm.cdf(x, mu, sigma) stats.norm.ppf(y, mu, sigma) stats.norm.rvs(mu, sigma) | #include <random> default_random_engine dre; normal_distribution<double> nd(mu, sigma); double x = nd(dre); |
gamma | Γ(k, θ) | [0,∞) | $$x^{k-1}\frac{exp(\frac{-x}{\theta})}{\Gamma(k) \theta^k}$$ | kθ | kθ2 | GAMMADIST(x, k, θ, FALSE) GAMMADIST(x, k, θ, TRUE) GAMMAINV(α, k, θ) GAMMAINV(RAND(), k, θ) | gampdf(x, k, theta) gamcdf(x, k, theta) gaminv(y, k, theta) gamrnd(k, theta) | dgamma(x, k, scale=theta) pgamma(x, k, scale=theta) qgamma(y, k, scale=theta) rgamma(1, k, scale=theta) | stats.gamma.pdf(x, k, scale=theta) stats.gamma.cdf(x, k, scale=theta) stats.gamma.ppf(y, k, scale=theta) stats.gamma.rvs(k, scale=theta) | #include <random> default_random_engine dre; gamma_distribution<double> gd(k, theta); double x = gd(dre); |
exponential | Exp(λ) | [0, ∞) | $$\lambda e^{-\lambda x}$$ | λ-1 | λ-2 | EXPON.DIST(x, λ, FALSE) EXPON.DIST(x, λ, TRUE) GAMMAINV(y, 1, 1/λ) GAMMAINV(RAND(), 1, 1/λ) | exppdf(x, lambda) expcdf(x, lambda) expinv(y, lambda) exprnd(lambda) | dexp(x, lambda) pexp(x, lambda) qexp(y, lambda) rexp(1, lambda) | stats.expon.pdf(x, scale=1.0/lambda) stats.expon.cdf(x, scale=1.0/lambda) stats.expon.ppf(x, scale=1.0/lambda) stats.expon.rvs(scale=1.0/lambda) | #include <random> default_random_engine dre; exponential_distribution<double> ed(lambda); double x = ed(dre); |
chi-squared | Χ2(ν) | [0, ∞) | $$\frac{1}{2^{k/2}\Gamma(k/2)} x^{k/2 - 1} e^{-x/2}$$ | ν | 2ν | CHISQ.DIST(x, ν, FALSE) CHISQ.DIST(x, ν, TRUE) CHISQ.INV(y, ν) CHISQ.INV(RAND(), ν) | chi2pdf(x, nu) chi2cdf(x, nu) chi2inv(y, nu) chi2rnd(nu) | dchisq(x, nu) pchisq(x, nu) qchisq(y, nu) rchisq(1, nu) | stats.chi2.pdf(x, nu) stats.chi2.cdf(x, nu) stats.chi2.ppf(y, nu) stats.chi2.rvs(nu) | #include <random> default_random_engine dre; chi_squared_distribution<double> csd(nu); double x = csd(dre); |
beta | Be(α, β) | [0, 1] | $$\frac{x^{\alpha-1}(1-x)^{\beta-1}}{B(\alpha, \beta)}$$ | $$\frac{\alpha}{\alpha + \beta}$$ | $$\frac{\alpha\beta}{(\alpha+\beta)^2(\alpha+\beta+1)}$$ | BETADIST(x, α, β, FALSE) BETADIST(x, α, β, TRUE) BETAINV(p, α, β) BETAINV(RAND(), α, β) | betapdf(x, alpha, beta) betacdf(x, alpha, beta) betainvf(y, alpha, beta) betarnd(alpha, beta) | dbeta(x, alpha, beta) pbeta(x, alpha, beta) qbeta(y, alpha, beta) rbeta(1, alpha, beta) | stats.beta.pdf(x, alpha, beta) stats.beta.cdf(x, alpha, beta) stats.beta.ppf(y, alpha, beta) stats.beta.rvs(alpha, beta) | none |
uniform | U(a, b) | [a, b] | $$\frac{1}{b-a}$$ | $$\frac{a+b}{2}$$ | $$\frac{(b-a)^2}{12}$$ | 1/(b-a) (x-a)/(b-a) α * (b-a) + a RAND()*(b-a) + a | unifpdf(x, a, b) unifcdf(x, a, b) unifinv(y, a, b) unifrnd(a, b) | dunif(x, a, b) punif(x, a, b) qunif(y, a, b) runif(1, a, b) | stats.uniform.pdf(x, a, b) stats.uniform.cdf(x, a, b) stats.uniform.ppf(y, a, b) stats.unifrom.rvs(a, b) | #include <random> default_random_engine dre; uniform_real_distribution<double> urd(a, b); double x = urd(dre); |
Student's t | t(ν) | (-∞,∞) | $$\frac{\Gamma(\frac{\nu+1}{2})}{\sqrt{\nu \pi} \Gamma(\frac{\nu}{2})} (1 + \frac{x^2}{\nu})^{-\frac{\nu+1}{2}}$$ | $$\begin{cases} 0 & \nu > 1 \\ \text{undefined} & \text{otherwise} \end{cases}$$ | $$\begin{cases} \frac{\nu}{\nu - 2} & \nu > 2 \\ \infty & 1 < \nu \le 2 \\ \text{undefined} & \text{otherwise} \end{cases}$$ | T.DIST(x, ν, FALSE) T.DIST(x, ν, TRUE) T.INV(α, ν) T.INV(RAND(), ν) | dt(x, nu) pt(x, nu) qt(y, nu) rt(1, nu) | stats.t.pdf(x, nu) stats.t.cdf(x, nu) stats.t.ppf(y, nu) stats.t.rvs(nu) | #include <random> default_random_engine dre; student_t_distribution<double> td(nu); double x = td(dre); | |
Snedecor's F | F(d1, d2) | [0, ∞) | $$\frac{\sqrt{\frac{(d_1 x)^{d_1} d_2^{d_2}}{(d_1 x + d_2)^{d_1+d_2}}}}{x B(d_1, d_2)}$$ | $$\frac{d_2}{d_2 - 2}$$ for d2 > 2 | F.DIST(x, d1, d2, FALSE) F.DIST(x, d1, d2, TRUE) F.INV(α, d1, d2) F.INV(RAND(), d1, d2) | df(x, d1, d2) pf(x, d1, d2) qf(y, d1, d2) rf(1, d1, d2) | stats.f.pdf(x, d1, d2) stats.f.cdf(x, d1, d2) stats.f.ppf(y, d1, d2) stats.f.rvs(d1, d2) | #include <random> default_random_engine dre; fisher_f_distribution<double> fd(d1, d2); double x = urd(dre); | ||
________ | __________________________ | _________________________ | _________________________ | ____________________________________ | ____________________________________________ |