Distributions
This serves as reference for all distribution objects that we implement in the ROLCH
package.
Note
This page is somewhat under construction, since MkDocs
does not support docstring inheritance at the moment.
All distributions are based on scipy.stats
distributions. We implement the probability density function (PDF), the cumulative density function (CDF), the percentage point or quantile function (PPF) and the random variates (RVS) accordingly as pass-through. The link functions are implemented in the same way as in GAMLSS (Rigby & Stasinopoulos, 2005). The link functions and their derivatives derive from the LinkFunction
base class.
Base Class
rolch.abc.Distribution
Bases: ABC
cdf
abstractmethod
The cumulative density function.
dl1_dp1
abstractmethod
Take the first derivative of the likelihood function with respect to the param.
dl2_dp2
abstractmethod
Take the second derivative of the likelihood function with respect to the param.
dl2_dpp
abstractmethod
Take the first derivative of the likelihood function with respect to both parameters.
initial_values
abstractmethod
Calculate the initial values for the GAMLSS fit.
link_function
abstractmethod
Apply the link function for param on y.
link_function_derivative
abstractmethod
Apply the derivative of the link function for param on y.
link_inverse
abstractmethod
Apply the inverse of the link function for param on y.
link_inverse_derivative
abstractmethod
Apply the derivative of the inverse link function for param on y.
ppf
abstractmethod
The percentage point or quantile function of the distribution.
rvs
abstractmethod
Draw random samples of shape size.
API Reference
rolch.DistributionNormal
rolch.DistributionT
rolch.DistributionJSU
Bases: Distribution
Corresponds to GAMLSS JSUo() and scipy.stats.johnsonsu()
Distribution parameters: 0 : Location 1 : Scale (close to standard deviation) 2 : Skewness 3 : Tail behaviour
rolch.DistributionGamma
Bases: Distribution
The Gamma Distribution for GAMLSS.
The distribution function is defined as in GAMLSS as: $$ f(y|\mu,\sigma)=\frac{y^{(1/\sigma^2-1)}\exp[-y/(\sigma^2 \mu)]}{(\sigma^2 \mu)^{(1/\sigma^2)} \Gamma(1/\sigma^2)} $$
with the location and shape parameters \(\mu, \sigma > 0\).
Note
The function is parameterized as GAMLSS' GA() distribution.
This parameterization is different to the scipy.stats.gamma(alpha, loc, scale)
parameterization.
We can use DistributionGamma().gamlss_to_scipy(mu, sigma)
to map the distribution parameters to scipy.
The scipy.stats.gamma()
distribution is defined as:
$$
f(x, \alpha, \beta) = \frac{\beta^\alpha x^{\alpha - 1} \exp[-\beta x]}{\Gamma(\alpha)}
$$
with the paramters \(\alpha, \beta >0\). The parameters can be mapped as follows: $$ \alpha = 1/\sigma^2 \Leftrightarrow \sigma = \sqrt{1 / \alpha} $$ and $$ \beta = 1/(\sigma^2\mu). $$
Parameters:
Name | Type | Description | Default |
---|---|---|---|
loc_link
|
LinkFunction
|
The link function for \(\mu\). Defaults to LogLink(). |
LogLink()
|
scale_link
|
LinkFunction
|
The link function for \(\sigma\). Defaults to LogLink(). |
LogLink()
|
gamlss_to_scipy
staticmethod
Map GAMLSS Parameters to scipy parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mu
|
ndarray
|
mu parameter |
required |
sigma
|
ndarray
|
sigma parameter |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
Tuple of (alpha, loc, scale) for scipy.stats.gamma(alpha, loc, scale) |