Sci.Dist: Statistical Distributions

In the following sd represents a generic one-dimensional statistical distribution. We loosely refer to sd for random variables distributed according to sd. Each sd has associated parameters which may be required to satisfy numerical constraints. If such constraints are violated an error is thrown.

API

xl, xu = sd:range()

Returns the minimum and the maximum possible theoretical values (infinite values allowed) assumed by sd.

v = sd:sample(rng)

The argument to the function must be a prng or a qrng object. In the first case the function generates independent and identically distributed random numbers according to the law of sd. In the second case the function returns samples which uniformly cover the range of sd according to the law of sd. Please notice that some statistical distributions do not support sampling via a qrng, in which case this fact is noted in the relevant documentation.

y = sd:pdf(x)

Returns the value of the probability density function (for continuous distributions) or of the mass probability function (for discrete distributions) computed at x for sd. The domain of this function is the real line.

y = sd:logpdf(x)

Returns the value of the natural logarithm of sd:pdf(). It is preferable to use this function instead of math.log(sd:pdf(x)). The domain of this function is the real line.

mean = sd:mean()

Returns the mean of sd. Returns an infinite number where appropriate or a nan number if the mean does not exist.

var = sd:var()

Returns the variance of sd. Returns an infinite number where appropriate or a nan number if the variance does not exist.

sdcopy = sd:copy()

Returns an independent copy of sd which is initialized with the same parameters of sd.

sd = dist.uniform($$\boldsymbol{a}$$, $$\boldsymbol{b}$$)

Constraint: $$a < b$$. Returns a continuous uniform distribution which is characterized by the pdf: $$f(x) = \frac{1}{b - a}, \quad x\in(a,b)$$

sd = dist.exponential($$\boldsymbol{\lambda}$$)

Constraint: $$\lambda > 0$$. Returns a continuous exponential distribution which is characterized by the pdf: $$f(x) = \lambda e^{-\lambda x}, \quad x\in(0,+\infty)$$

sd = dist.normal($$\boldsymbol{\mu}$$, $$\boldsymbol{\sigma}$$)

Constraint: $$\sigma > 0$$. Returns a continuous normal (Gaussian) distribution which is characterized by the pdf: $$f(x) = \frac{1}{\sqrt{2\pi}\sigma}\exp{\{-\frac{(x - \mu)^2}{2\sigma^2}\}}, \quad x\in(-\infty,+\infty)$$

sd = dist.lognormal($$\boldsymbol{\mu}$$, $$\boldsymbol{\sigma}$$)

Constraint: $$\sigma > 0$$. Returns a continuous log-normal distribution which is characterized by the pdf: $$f(x) = \frac{1}{\sqrt{2\pi}\sigma x}\exp{\{-\frac{(\ln{x} - \mu)^2}{2\sigma^2}\}}, \quad x\in(0,+\infty)$$

sd = dist.student($$\boldsymbol{\nu}$$)

Constraint: $$\nu > 0$$. Returns a continuous student's t-distribution which is characterized by the pdf: $$f(x) = \frac{1}{\sqrt{\nu}\text{B}\left(\frac{1}{2},\frac{\nu}{2}\right)}\left(1 + \frac{x^2}{2}\right)^{-\frac{\nu + 1}{2}}, \quad x\in(-\infty,+\infty)$$ where $$\text{B}$$ is the beta function.

sd = dist.gamma($$\boldsymbol{\alpha}$$, $$\boldsymbol{\beta}$$)

Constraint: $$\alpha > 0$$ and $$\beta > 0$$. Returns a continuous gamma distribution with shape parameter $$\alpha$$ and rate parameter $$\beta$$ which is characterized by the pdf: $$f(x) = \frac{\beta^\alpha}{\Gamma(\alpha)}x^{\alpha-1}e^{-\beta x}, \quad x\in(0,+\infty)$$ where $$\Gamma$$ is the gamma function. This distribution does not allow sampling via a qrng.

sd = dist.beta($$\boldsymbol{\alpha}$$, $$\boldsymbol{\beta}$$)

Constraint: $$\alpha > 0$$ and $$\beta > 0$$. Returns a continuous beta distribution which is characterized by the pdf: $$f(x) = \frac{1}{\text{B}(\alpha,\beta)}x^{\alpha-1}(1-x)^{\beta-1}, \quad x\in(0,1)$$ where $$\text{B}$$ is the beta function. This distribution does not allow sampling via a qrng

.