Univariate Discrete Distributions¶

Bernoulli
(p)¶ A Bernoulli distribution is parameterized by a success rate
p
, which takes value 1 with probabilityp
and 0 with probability1p
.\[\begin{split}P(X = k) = \begin{cases} 1  p & \quad \text{for } k = 0, \\ p & \quad \text{for } k = 1. \end{cases}\end{split}\]Bernoulli() # Bernoulli distribution with p = 0.5 Bernoulli(p) # Bernoulli distribution with success rate p params(d) # Get the parameters, i.e. (p,) succprob(d) # Get the success rate, i.e. p failprob(d) # Get the failure rate, i.e. 1  p
External links:

BetaBinomial
(n, α, β)¶ A Betabinomial distribution is the compound distribution of the
Binomial()
distribution where the probability of successp
is distributed according to theBeta()
. It has three parameters:n
, the number of trials and two shape parametersα
,β
\[P(X = k) = {n \choose k} B(k + \alpha, n  k + \beta) / B(\alpha, \beta), \quad \text{ for } k = 0,1,2, \ldots, n.\]BetaBinomial(n, a, b) # BetaBinomial distribution with n trials and shape parameters a, b params(d) # Get the parameters, i.e. (n, a, b) ntrials(d) # Get the number of trials, i.e. n
External links:

Binomial
(n, p)¶ A Binomial distribution characterizes the number of successes in a sequence of independent trials. It has two parameters:
n
, the number of trials, andp
, the probability of success in an individual trial, with the distribution:\[P(X = k) = {n \choose k}p^k(1p)^{nk}, \quad \text{ for } k = 0,1,2, \ldots, n.\]Binomial() # Binomial distribution with n = 1 and p = 0.5 Binomial(n) # Binomial distribution for n trials with success rate p = 0.5 Binomial(n, p) # Binomial distribution for n trials with success rate p params(d) # Get the parameters, i.e. (n, p) ntrials(d) # Get the number of trials, i.e. n succprob(d) # Get the success rate, i.e. p failprob(d) # Get the failure rate, i.e. 1  p
External links:

Categorical
(p)¶ A Categorical distribution is parameterized by a probability vector
p
(of lengthK
).\[P(X = k) = p[k] \quad \text{for } k = 1, 2, \ldots, K.\]Categorical(p) # Categorical distribution with probability vector p params(d) # Get the parameters, i.e. (p,) probs(d) # Get the probability vector, i.e. p ncategories(d) # Get the number of categories, i.e. K
Here,
p
must be a real vector, of which all components are nonnegative and sum to one.Note: The input vector
p
is directly used as a field of the constructed distribution, without being copied.External links:

DiscreteUniform
(a, b)¶ A Discrete uniform distribution is a uniform distribution over a consecutive sequence of integers between
a
andb
, inclusive.\[P(X = k) = 1 / (b  a + 1) \quad \text{for } k = a, a+1, \ldots, b.\]DiscreteUniform(a, b) # a uniform distribution over {a, a+1, ..., b} params(d) # Get the parameters, i.e. (a, b) span(d) # Get the span of the support, i.e. (b  a + 1) probval(d) # Get the probability value, i.e. 1 / (b  a + 1) minimum(d) # Return a maximum(d) # Return b
External links

Geometric
(p)¶ A Geometric distribution characterizes the number of failures before the first success in a sequence of independent Bernoulli trials with success rate
p
.\[P(X = k) = p (1  p)^k, \quad \text{for } k = 0, 1, 2, \ldots.\]Geometric() # Geometric distribution with success rate 0.5 Geometric(p) # Geometric distribution with success rate p params(d) # Get the parameters, i.e. (p,) succprob(d) # Get the success rate, i.e. p failprob(d) # Get the failure rate, i.e. 1  p
External links

Hypergeometric
(s, f, n)¶ A Hypergeometric distribution describes the number of successes in
n
draws without replacement from a finite population containings
successes andf
failures.\[P(X = k) = {{{s \choose k} {f \choose {nk}}}\over {s+f \choose n}}, \quad \text{for } k = \max(0, n  f), \ldots, \min(n, s).\]Hypergeometric(s, f, n) # Hypergeometric distribution for a population with # s successes and f failures, and a sequence of n trials. params(d) # Get the parameters, i.e. (s, f, n)
External links

NegativeBinomial
(r, p)¶ A Negative binomial distribution describes the number of failures before the
r
th success in a sequence of independent Bernoulli trials. It is parameterized byr
, the number of successes, andp
, the probability of success in an individual trial.\[P(X = k) = {k + r  1 \choose k} p^r (1  p)^k, \quad \text{for } k = 0,1,2,\ldots.\]The distribution remains welldefined for any positive
r
, in which case\[P(X = k) = \frac{\Gamma(k+r)}{k! \Gamma(r)} p^r (1  p)^k, \quad \text{for } k = 0,1,2,\ldots.\]NegativeBinomial() # Negative binomial distribution with r = 1 and p = 0.5 NegativeBinomial(r, p) # Negative binomial distribution with r successes and success rate p params(d) # Get the parameters, i.e. (r, p) succprob(d) # Get the success rate, i.e. p failprob(d) # Get the failure rate, i.e. 1  p
External links:

Poisson
(λ)¶ A Poisson distribution descibes the number of independent events occurring within a unit time interval, given the average rate of occurrence
λ
.\[P(X = k) = \frac{\lambda^k}{k!} e^{\lambda}, \quad \text{ for } k = 0,1,2,\ldots.\]Poisson() # Poisson distribution with rate parameter 1 Poisson(lambda) # Poisson distribution with rate parameter lambda params(d) # Get the parameters, i.e. (λ,) mean(d) # Get the mean arrival rate, i.e. λ
External links:

PoissonBinomial
(p)¶ A Poissonbinomial distribution describes the number of successes in a sequence of independent trials, wherein each trial has a different success rate. It is parameterized by a vector
p
(of lengthK
), whereK
is the total number of trials andp[i]
corresponds to the probability of success of thei
th trial.\[P(X = k) = \sum\limits_{A\in F_k} \prod\limits_{i\in A} p[i] \prod\limits_{j\in A^c} (1p[j]), \quad \text{ for } k = 0,1,2,\ldots,K,\]where \(F_k\) is the set of all subsets of \(k\) integers that can be selected from \(\{1,2,3,...,K\}\).
PoissonBinomial(p) # Poisson Binomial distribution with success rate vector p params(d) # Get the parameters, i.e. (p,) succprob(d) # Get the vector of success rates, i.e. p failprob(d) # Get the vector of failure rates, i.e. 1p
External links:

Skellam
(μ1, μ2)¶ A Skellam distribution describes the difference between two independent
Poisson()
variables, respectively with rateμ1
andμ2
.\[P(X = k) = e^{(\mu_1 + \mu_2)} \left( \frac{\mu_1}{\mu_2} \right)^{k/2} I_k(2 \sqrt{\mu_1 \mu_2}) \quad \text{for integer } k\]where \(I_k\) is the modified Bessel function of the first kind.
Skellam(mu1, mu2) # Skellam distribution for the difference between two Poisson variables, # respectively with expected values mu1 and mu2. params(d) # Get the parameters, i.e. (mu1, mu2)
External links: