Custom distributions#
Custom parametrization of scipy.stats distributions is available in Pykelihood
to align with statistical community standards. In a later version of Pykelihood,
we aim to include re-parametrization of a base distribution as a feature of
the ``Distribution` class. Custom distributions might thus be deprecated in the future.
- class Beta(loc=0.0, scale=1.0, alpha=2.0, beta=1.0)#
Beta distribution.
- Parameters:
loc (float, optional) – Location parameter, by default 0.0.
scale (float, optional) – Scale parameter, by default 1.0.
alpha (float, optional) – Alpha parameter, by default 2.0.
beta (float, optional) – Beta parameter, by default 1.0.
- property params_names#
Return the names of the parameters.
- class Exponential(loc=0.0, rate=1.0)#
Exponential distribution.
- Parameters:
loc (float, optional) – Location parameter, by default 0.0.
rate (float, optional) – Rate parameter, by default 1.0.
- property params_names#
Return the names of the parameters.
- class GEV(loc=0.0, scale=1.0, shape=0.0)#
Generalized Extreme Value (GEV) distribution.
- Parameters:
loc (float, optional) – Location parameter, by default 0.0.
scale (float, optional) – Scale parameter, by default 1.0.
shape (float, optional) – Shape parameter, by default 0.0.
Notes
This version of the Generalized Extreme Value distribution (GEV) does not have parameters c, loc, scale but loc, scale and shape where shape is -c.
- lb_shape(data)#
Calculate the lower bound of the shape parameter.
- Parameters:
data (array-like) – Data to calculate the lower bound.
- Returns:
Lower bound of the shape parameter.
- Return type:
float
- property params_names#
Return the names of the parameters.
- ub_shape(data)#
Calculate the upper bound of the shape parameter.
- Parameters:
data (array-like) – Data to calculate the upper bound.
- Returns:
Upper bound of the shape parameter.
- Return type:
float
- class GPD(loc=0.0, scale=1.0, shape=0.0)#
Generalized Pareto Distribution (GPD).
- Parameters:
loc (float, optional) – Location parameter, by default 0.0.
scale (float, optional) – Scale parameter, by default 1.0.
shape (float, optional) – Shape parameter, by default 0.0.
- property params_names#
Return the names of the parameters.
- class Gamma(loc=0.0, scale=1.0, shape=0.0)#
Gamma distribution.
- Parameters:
loc (float, optional) – Location parameter, by default 0.0.
scale (float, optional) – Scale parameter, by default 1.0.
shape (float, optional) – Shape parameter, by default 0.0.
- property params_names#
Return the names of the parameters.
- class Pareto(loc=0.0, scale=1.0, alpha=1.0)#
Pareto distribution.
- Parameters:
loc (float, optional) – Location parameter, by default 0.0.
scale (float, optional) – Scale parameter, by default 1.0.
alpha (float, optional) – Shape parameter, by default 1.0.
- property params_names#
Return the names of the parameters.
- class TruncatedDistribution(distribution, lower_bound=-inf, upper_bound=inf)#
Truncated distribution.
- Parameters:
distribution (Distribution) – The base distribution to truncate.
lower_bound (float, optional) – Lower bound of the distribution, by default -np.inf.
upper_bound (float, optional) – Upper bound of the distribution, by default np.inf.
- Raises:
ValueError – If the lower and upper bounds are equal.
- cdf(x)#
Cumulative distribution function.
- Parameters:
x (Obs) – Data to evaluate.
- Returns:
Cumulative distribution values.
- Return type:
np.ndarray
- fit(*args, **kwargs)#
Fit the instance to the data.
- Parameters:
args (tuple) – Positional arguments.
kwargs (dict) – Keyword arguments.
- Returns:
The fitted instance.
- Return type:
- isf(q)#
Inverse survival function.
- Parameters:
q (Obs) – Quantiles to evaluate.
- Returns:
Inverse survival function values.
- Return type:
np.ndarray
- property params_names#
Get the names of the parameters.
- Returns:
The parameter names.
- Return type:
tuple[str, …]
- pdf(x)#
Probability density function.
- Parameters:
x (Obs) – Data to evaluate.
- Returns:
Probability density values.
- Return type:
np.ndarray
- ppf(q)#
Percent point function (inverse of cdf).
- Parameters:
q (Obs) – Quantiles to evaluate.
- Returns:
Percent point function values.
- Return type:
np.ndarray
- rvs(size, *args, **kwargs)#
Generate random variates.
- Parameters:
size (int) – Number of random variates to generate.
args (tuple) – Positional arguments.
kwargs (dict) – Keyword arguments.
- Returns:
Random variates.
- Return type:
np.ndarray