Distributions
The distributions module provides various statistical distributions for generating stochastic variables.
Distributions Module.
This module contains classes for simulating statistical distributions. The implementations follow conventions similar to Klugman. Random number generation and GPU support are managed via configuration settings.
It’s expected that you construct distributions of distributions ie. a distribution can be created and passed to another distribution as a parameter.
Note on Type Signatures: Distributions accept and return only primitives (int, float) or StochasticScalar. The DistributionParameter type alias is Union[int, float, StochasticScalar]. Internally, scipy.special functions may operate on arrays extracted from StochasticScalar.values, but the public API never exposes raw numpy arrays.
Type Definitions: - DistributionParameter: Union[int, float, StochasticScalar] - ReturnType: Union[int, float, StochasticScalar]
- class pal.distributions.DistributionBase(**params)[source]
Bases:
objectAbstract base class for statistical distributions.
- cdf(x)[source]
Compute the cumulative distribution function at x.
- Parameters:
x (
Union[int,float,StochasticScalar]) – Single value or sequence of values to evaluate.- Return type:
Union[int,float,StochasticScalar]- Returns:
CDF value(s) - same type as input (Numeric -> Numeric, Sequence -> Sequence).
- invcdf(u)[source]
Compute the inverse cumulative distribution function at u.
- Parameters:
u (
Union[int,float,StochasticScalar]) – Single probability or sequence of probabilities to evaluate.- Return type:
Union[int,float,StochasticScalar]- Returns:
Quantile value(s) - same type as input (Numeric -> Numeric, Sequence -> Sequence).
- class pal.distributions.DiscreteDistributionBase(**params)[source]
Bases:
DistributionBase,ABCAbstract base class for discrete distributions.
- __init__(**params)
Initialize distribution with parameters.
- cdf(x)
Compute the cumulative distribution function at x.
- Parameters:
x (
Union[int,float,StochasticScalar]) – Single value or sequence of values to evaluate.- Return type:
Union[int,float,StochasticScalar]- Returns:
CDF value(s) - same type as input (Numeric -> Numeric, Sequence -> Sequence).
- generate(n_sims=None, rng=None)
Generate random samples from the distribution.
- Parameters:
- Returns:
Generated samples.
- Return type:
- invcdf(u)
Compute the inverse cumulative distribution function at u.
- Parameters:
u (
Union[int,float,StochasticScalar]) – Single probability or sequence of probabilities to evaluate.- Return type:
Union[int,float,StochasticScalar]- Returns:
Quantile value(s) - same type as input (Numeric -> Numeric, Sequence -> Sequence).
- class pal.distributions.Poisson(mean)[source]
Bases:
DiscreteDistributionBasePoisson Distribution.
The probability mass function (PMF) is:
\[P(X = k) = \frac{\lambda^k e^{-\lambda}}{k!}, \quad k = 0, 1, 2, \ldots\]where \(\lambda > 0\) is the mean (and variance) of the distribution.
The cumulative distribution function is:
\[F(k) = e^{-\lambda} \sum_{i=0}^{\lfloor k \rfloor} \frac{\lambda^i}{i!}\]- Parameters:
mean (
Union[int,float,StochasticScalar]) – Mean number of events \(\lambda\).
- cdf(x)[source]
Compute cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- invcdf(u)[source]
Compute inverse cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.NegBinomial(n, p)[source]
Bases:
DiscreteDistributionBaseNegative Binomial Distribution.
The probability mass function (PMF) is:
\[P(X = k) = \binom{k + r - 1}{k} p^r (1-p)^k, \quad k = 0, 1, 2, \ldots\]where \(r > 0\) is the number of failures until stop and \(0 < p < 1\) is the probability of success.
Often used to model overdispersed count data.
- __init__(n, p)[source]
Initialize negative binomial distribution.
- Parameters:
n (
Union[int,float,StochasticScalar]) – Number of failures until stop.p (
Union[int,float,StochasticScalar]) – Probability of success.
- cdf(x)[source]
Compute cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- invcdf(u)[source]
Compute inverse cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.Binomial(n, p)[source]
Bases:
DiscreteDistributionBaseBinomial Distribution.
The probability mass function (PMF) is:
\[P(X = k) = \binom{n}{k} p^k (1-p)^{n-k}, \quad k = 0, 1, \ldots, n\]where \(n\) is the number of trials and \(0 \leq p \leq 1\) is the probability of success on each trial.
Models the number of successes in a fixed number of independent Bernoulli trials.
- __init__(n, p)[source]
Initialize binomial distribution.
- Parameters:
n (
Union[int,float,StochasticScalar]) – Number of trials.p (
Union[int,float,StochasticScalar]) – Probability of success.
- cdf(x)[source]
Compute cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- invcdf(u)[source]
Compute inverse cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.HyperGeometric(ngood, nbad, n_draws)[source]
Bases:
DiscreteDistributionBaseHypergeometric Distribution.
The probability mass function (PMF) is:
\[P(X = k) = \frac{\binom{K}{k}\binom{N-K}{n-k}}{\binom{N}{n}}\]where \(N\) is the population size, \(K\) is the number of success states in the population, \(n\) is the number of draws, and \(k\) is the number of observed successes.
Models the number of successes in draws without replacement from a finite population.
- Parameters:
- cdf(x)[source]
Compute cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- invcdf(u)[source]
Compute inverse cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.Bernoulli(p)[source]
Bases:
BinomialBernoulli Distribution.
The probability mass function (PMF) is:
\[P(X = k) = p^k (1-p)^{1-k}, \quad k = 0, 1\]where \(0 \leq p \leq 1\) is the probability of success.
Models a single trial with two possible outcomes: success (1) or failure (0).
- __init__(p)[source]
Initialize Bernoulli distribution.
- Parameters:
p (
Union[int,float,StochasticScalar]) – Probability of success.
- cdf(x)
Compute cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- generate(n_sims=None, rng=None)
Generate random samples from the distribution.
- Parameters:
- Returns:
Generated samples.
- Return type:
- invcdf(u)
Compute inverse cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.GPD(shape, scale, loc)[source]
Bases:
DistributionBaseGeneralized Pareto Distribution.
The cumulative distribution function (CDF) is:
\[\begin{split}F(x) = \begin{cases} 1 - \left(1 + \frac{\xi(x-\mu)}{\sigma}\right)^{-1/\xi} & \text{for } \xi \neq 0 \\ 1 - \exp\left(-\frac{x-\mu}{\sigma}\right) & \text{for } \xi = 0 \end{cases}\end{split}\]where \(\xi\) is the shape parameter, \(\sigma\) is the scale parameter, and \(\mu\) is the location parameter.
- __init__(shape, scale, loc)[source]
Initialize GPD distribution.
- Parameters:
shape (
Union[int,float,StochasticScalar]) – Shape parameter.scale (
Union[int,float,StochasticScalar]) – Scale parameter.loc (
Union[int,float,StochasticScalar]) – Location parameter.
- cdf(x)[source]
Compute cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- invcdf(u)[source]
Compute inverse cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.Burr(power, shape, scale, loc)[source]
Bases:
DistributionBaseBurr Distribution.
The cumulative distribution function (CDF) is:
\[F(x) = 1 - \left[1 + \left(\frac{x-\mu}{\sigma}\right)^c\right]^{-k}, \quad x > \mu\]where \(c\) is the power parameter, \(k\) is the shape parameter, \(\sigma\) is the scale parameter, and \(\mu\) is the location parameter.
- Parameters:
power (
Union[int,float,StochasticScalar]) – The power parameter \(c\).shape (
Union[int,float,StochasticScalar]) – The shape parameter \(k\).scale (
Union[int,float,StochasticScalar]) – The scale parameter \(\sigma\).loc (
Union[int,float,StochasticScalar]) – The location parameter \(\mu\).
- __init__(power, shape, scale, loc)[source]
Initialize Burr distribution.
- Parameters:
power (
Union[int,float,StochasticScalar]) – Power parameter.shape (
Union[int,float,StochasticScalar]) – Shape parameter.scale (
Union[int,float,StochasticScalar]) – Scale parameter.loc (
Union[int,float,StochasticScalar]) – Location parameter.
- cdf(x)[source]
Compute cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- invcdf(u)[source]
Compute inverse cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.Beta(alpha, beta, scale=1.0, loc=0.0)[source]
Bases:
DistributionBaseBeta Distribution.
The cumulative distribution function (CDF) is:
\[F(x) = I_{(x-\mu)/\sigma}(\alpha, \beta) = \frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)} \int_0^{(x-\mu)/\sigma} t^{\alpha-1}(1-t)^{\beta-1} dt\]where \(I_x(\alpha, \beta)\) is the regularized incomplete beta function, \(\Gamma\) is the gamma function, \(\alpha\) and \(\beta\) are shape parameters, \(\sigma\) is the scale parameter, and \(\mu\) is the location parameter.
- Parameters:
alpha (
Union[int,float,StochasticScalar]) – Alpha shape parameter \(\alpha > 0\).beta (
Union[int,float,StochasticScalar]) – Beta shape parameter \(\beta > 0\).scale (
Union[int,float,StochasticScalar]) – Scale parameter \(\sigma\) (default 1.0).loc (
Union[int,float,StochasticScalar]) – Location parameter \(\mu\) (default 0.0).
- __init__(alpha, beta, scale=1.0, loc=0.0)[source]
Initialize beta distribution.
- Parameters:
alpha (
Union[int,float,StochasticScalar]) – Alpha parameter.beta (
Union[int,float,StochasticScalar]) – Beta parameter.scale (
Union[int,float,StochasticScalar]) – Scale parameter.loc (
Union[int,float,StochasticScalar]) – Location parameter.
- cdf(x)[source]
Compute cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- invcdf(u)[source]
Compute inverse cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.LogLogistic(shape, scale, loc=0.0)[source]
Bases:
DistributionBaseLog-Logistic Distribution.
The cumulative distribution function (CDF) is:
\[F(x) = \frac{y}{1 + y}, \quad \text{where } y = \left(\frac{x-\mu}{\sigma}\right)^\alpha, \quad x > \mu\]where \(\alpha\) is the shape parameter, \(\sigma\) is the scale parameter, and \(\mu\) is the location parameter.
- Parameters:
shape (
Union[int,float,StochasticScalar]) – Shape parameter \(\alpha\).scale (
Union[int,float,StochasticScalar]) – Scale parameter \(\sigma\).loc (
Union[int,float,StochasticScalar]) – Location parameter \(\mu\) (default 0.0).
- __init__(shape, scale, loc=0.0)[source]
Initialize log-logistic distribution.
- Parameters:
shape (
Union[int,float,StochasticScalar]) – Shape parameter.scale (
Union[int,float,StochasticScalar]) – Scale parameter.loc (
Union[int,float,StochasticScalar]) – Location parameter.
- cdf(x)[source]
Compute the cumulative distribution function at x.
- Parameters:
x (
Union[int,float,StochasticScalar]) – Single value or sequence of values to evaluate.- Return type:
Union[int,float,StochasticScalar]- Returns:
CDF value(s) - same type as input (Numeric -> Numeric, Sequence -> Sequence).
- invcdf(u)[source]
Compute the inverse cumulative distribution function at u.
- Parameters:
u (
Union[int,float,StochasticScalar]) – Single probability or sequence of probabilities to evaluate.- Return type:
Union[int,float,StochasticScalar]- Returns:
Quantile value(s) - same type as input (Numeric -> Numeric, Sequence -> Sequence).
- class pal.distributions.Normal(mu, sigma)[source]
Bases:
DistributionBaseNormal (Gaussian) Distribution.
The cumulative distribution function (CDF) is:
\[F(x) = \Phi\left(\frac{x - \mu}{\sigma}\right) = \frac{1}{2}\left[1 + \text{erf}\left( \frac{x - \mu}{\sigma\sqrt{2}}\right)\right]\]where \(\Phi\) is the standard normal CDF, \(\mu\) is the mean, and \(\sigma > 0\) is the standard deviation.
The probability density function is:
\[f(x) = \frac{1}{\sigma\sqrt{2\pi}} \exp\left(-\frac{(x-\mu)^2}{2\sigma^2}\right)\]- __init__(mu, sigma)[source]
Initialize normal distribution.
- Parameters:
mu (
Union[int,float,StochasticScalar]) – Mean parameter.sigma (
Union[int,float,StochasticScalar]) – Standard deviation parameter.
- cdf(x)[source]
Compute cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- invcdf(u)[source]
Compute inverse cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.Logistic(mu, sigma)[source]
Bases:
DistributionBaseLogistic Distribution.
The cumulative distribution function (CDF) is:
\[F(x) = \frac{1}{1 + e^{-(x-\mu)/\sigma}}\]where \(\mu\) is the location parameter and \(\sigma > 0\) is the scale parameter.
The logistic distribution has heavier tails than the normal distribution.
- __init__(mu, sigma)[source]
Initialize logistic distribution.
- Parameters:
mu (
Union[int,float,StochasticScalar]) – Location parameter.sigma (
Union[int,float,StochasticScalar]) – Scale parameter.
- cdf(x)[source]
Compute cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- invcdf(u)[source]
Compute inverse cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.LogNormal(mu, sigma)[source]
Bases:
DistributionBaseLog-Normal Distribution.
The cumulative distribution function (CDF) is:
\[F(x) = \Phi\left(\frac{\ln(x) - \mu}{\sigma}\right)\]where \(\Phi\) is the standard normal CDF, \(\mu\) is the mean of the logarithm of the variable, and \(\sigma > 0\) is the standard deviation of the logarithm.
If \(Y = \ln(X)\) is normally distributed with mean \(\mu\) and standard deviation \(\sigma\), then \(X\) follows a log-normal distribution.
- __init__(mu, sigma)[source]
Initialize log-normal distribution.
- Parameters:
mu (
Union[int,float,StochasticScalar]) – Mean of the logged variable.sigma (
Union[int,float,StochasticScalar]) – Standard deviation of the logged variable.
- cdf(x)[source]
Compute cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- invcdf(u)[source]
Compute inverse cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.Gamma(alpha, theta, loc=0.0)[source]
Bases:
DistributionBaseGamma Distribution.
The cumulative distribution function (CDF) is:
\[F(x) = \frac{1}{\Gamma(\alpha)} \gamma\left(\alpha, \frac{x-\mu}{\theta}\right), \quad x > \mu\]where \(\Gamma(\alpha)\) is the gamma function, \(\gamma(\alpha, z)\) is the lower incomplete gamma function, \(\alpha\) is the shape parameter, \(\theta\) is the scale parameter, and \(\mu\) is the location parameter.
- __init__(alpha, theta, loc=0.0)[source]
Initialize gamma distribution.
- Parameters:
alpha (
Union[int,float,StochasticScalar]) – Shape parameter.theta (
Union[int,float,StochasticScalar]) – Scale parameter.loc (
Union[int,float,StochasticScalar]) – Location parameter.
- cdf(x)[source]
Compute cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- invcdf(u)[source]
Compute inverse cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.InverseGamma(alpha, theta, loc=0.0)[source]
Bases:
DistributionBaseInverse Gamma Distribution.
The cumulative distribution function (CDF) is:
\[F(x) = 1 - \frac{1}{\Gamma(\alpha)} \gamma\left(\alpha, \frac{\theta}{x-\mu}\right), \quad x > \mu\]where \(\Gamma(\alpha)\) is the gamma function, \(\gamma(\alpha, z)\) is the lower incomplete gamma function, \(\alpha > 0\) is the shape parameter, \(\theta > 0\) is the scale parameter, and \(\mu\) is the location parameter.
- __init__(alpha, theta, loc=0.0)[source]
Initialize inverse gamma distribution.
- Parameters:
alpha (
Union[int,float,StochasticScalar]) – Shape parameter.theta (
Union[int,float,StochasticScalar]) – Scale parameter.loc (
Union[int,float,StochasticScalar]) – Location parameter.
- cdf(x)[source]
Compute cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- invcdf(u)[source]
Compute inverse cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.Pareto(shape, scale)[source]
Bases:
DistributionBasePareto Distribution.
The cumulative distribution function (CDF) is:
\[F(x) = 1 - \left(\frac{x_m}{x}\right)^\alpha, \quad x \geq x_m\]where \(\alpha > 0\) is the shape parameter (tail index) and \(x_m > 0\) is the scale parameter (minimum value).
The Pareto distribution is a power-law probability distribution often used to model heavy-tailed phenomena in actuarial science and economics.
- __init__(shape, scale)[source]
Initialize Pareto distribution.
- Parameters:
shape (
Union[int,float,StochasticScalar]) – Shape parameter.scale (
Union[int,float,StochasticScalar]) – Scale parameter.
- cdf(x)[source]
Compute cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- invcdf(u)[source]
Compute inverse cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.Paralogistic(shape, scale, loc=0.0)[source]
Bases:
DistributionBaseParaLogistic Distribution.
The cumulative distribution function (CDF) is:
\[F(x) = 1 - \left[1 + \left(\frac{x-\mu}{\sigma}\right)^\alpha\right]^{-\alpha}, \quad x > \mu\]where \(\alpha > 0\) is the shape parameter, \(\sigma > 0\) is the scale parameter, and \(\mu\) is the location parameter.
- Parameters:
shape (
Union[int,float,StochasticScalar]) – Shape parameter \(\alpha\).scale (
Union[int,float,StochasticScalar]) – Scale parameter \(\sigma\).loc (
Union[int,float,StochasticScalar]) – Location parameter \(\mu\) (default 0).
- __init__(shape, scale, loc=0.0)[source]
Initialize paralogistic distribution.
- Parameters:
shape (
Union[int,float,StochasticScalar]) – Shape parameter.scale (
Union[int,float,StochasticScalar]) – Scale parameter.loc (
Union[int,float,StochasticScalar]) – Location parameter.
- cdf(x)[source]
Compute the cumulative distribution function at x.
- Parameters:
x (
Union[int,float,StochasticScalar]) – Single value or sequence of values to evaluate.- Return type:
Union[int,float,StochasticScalar]- Returns:
CDF value(s) - same type as input (Numeric -> Numeric, Sequence -> Sequence).
- invcdf(u)[source]
Compute the inverse cumulative distribution function at u.
- Parameters:
u (
Union[int,float,StochasticScalar]) – Single probability or sequence of probabilities to evaluate.- Return type:
Union[int,float,StochasticScalar]- Returns:
Quantile value(s) - same type as input (Numeric -> Numeric, Sequence -> Sequence).
- class pal.distributions.InverseBurr(power, shape, scale, loc)[source]
Bases:
DistributionBaseInverse Burr Distribution.
The cumulative distribution function (CDF) is:
\[F(x) = \left[\frac{\left(\frac{x-\mu}{\sigma}\right)^\tau} {1 + \left(\frac{x-\mu}{\sigma}\right)^\tau}\right]^\alpha\]where \(\tau > 0\) is the power parameter, \(\alpha > 0\) is the shape parameter, \(\sigma > 0\) is the scale parameter, and \(\mu\) is the location parameter.
- Parameters:
power (
Union[int,float,StochasticScalar]) – Power parameter \(\tau\).shape (
Union[int,float,StochasticScalar]) – Shape parameter \(\alpha\).scale (
Union[int,float,StochasticScalar]) – Scale parameter \(\sigma\).loc (
Union[int,float,StochasticScalar]) – Location parameter \(\mu\).
- __init__(power, shape, scale, loc)[source]
Initialize inverse Burr distribution.
- Parameters:
power (
Union[int,float,StochasticScalar]) – Power parameter.shape (
Union[int,float,StochasticScalar]) – Shape parameter.scale (
Union[int,float,StochasticScalar]) – Scale parameter.loc (
Union[int,float,StochasticScalar]) – Location parameter.
- cdf(x)[source]
Compute the cumulative distribution function at x.
- Parameters:
x (
Union[int,float,StochasticScalar]) – Single value or sequence of values to evaluate.- Return type:
Union[int,float,StochasticScalar]- Returns:
CDF value(s) - same type as input (Numeric -> Numeric, Sequence -> Sequence).
- invcdf(u)[source]
Compute inverse cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.InverseParalogistic(shape, scale, loc=0.0)[source]
Bases:
DistributionBaseInverse ParaLogistic Distribution.
The cumulative distribution function (CDF) is:
\[F(x) = \left[\frac{\left(\frac{x-\mu}{\sigma}\right)^\alpha} {1 + \left(\frac{x-\mu}{\sigma}\right)^\alpha}\right]^\alpha, \quad x > \mu\]where \(\alpha > 0\) is the shape parameter, \(\sigma > 0\) is the scale parameter, and \(\mu\) is the location parameter.
- __init__(shape, scale, loc=0.0)[source]
Initialize inverse paralogistic distribution.
- Parameters:
shape (
Union[int,float,StochasticScalar]) – Shape parameter.scale (
Union[int,float,StochasticScalar]) – Scale parameter.loc (
Union[int,float,StochasticScalar]) – Location parameter.
- cdf(x)[source]
Compute the cumulative distribution function at x.
- Parameters:
x (
Union[int,float,StochasticScalar]) – Single value or sequence of values to evaluate.- Return type:
Union[int,float,StochasticScalar]- Returns:
CDF value(s) - same type as input (Numeric -> Numeric, Sequence -> Sequence).
- invcdf(u)[source]
Compute the inverse cumulative distribution function at u.
- Parameters:
u (
Union[int,float,StochasticScalar]) – Single probability or sequence of probabilities to evaluate.- Return type:
Union[int,float,StochasticScalar]- Returns:
Quantile value(s) - same type as input (Numeric -> Numeric, Sequence -> Sequence).
- class pal.distributions.Weibull(shape, scale, loc=0)[source]
Bases:
DistributionBaseWeibull Distribution.
The cumulative distribution function (CDF) is:
\[F(x) = 1 - \exp\left[-\left(\frac{x-\mu}{\sigma}\right)^\alpha\right], \quad x > \mu\]where \(\alpha > 0\) is the shape parameter, \(\sigma > 0\) is the scale parameter, and \(\mu\) is the location parameter.
The Weibull distribution is widely used in reliability engineering and failure analysis.
- cdf(x)[source]
Compute cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- invcdf(u)[source]
Compute inverse cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.InverseWeibull(shape, scale, loc=0)[source]
Bases:
DistributionBaseInverse Weibull Distribution.
The cumulative distribution function (CDF) is:
\[F(x) = \exp\left[-\left(\frac{x-\mu}{\sigma}\right)^{-\alpha}\right], \quad x > \mu\]where \(\alpha > 0\) is the shape parameter, \(\sigma > 0\) is the scale parameter, and \(\mu\) is the location parameter.
Also known as the Fréchet distribution.
- Parameters:
- cdf(x)[source]
Compute the cumulative distribution function at x.
- Parameters:
x (
Union[int,float,StochasticScalar]) – Single value or sequence of values to evaluate.- Return type:
Union[int,float,StochasticScalar]- Returns:
CDF value(s) - same type as input (Numeric -> Numeric, Sequence -> Sequence).
- invcdf(u)[source]
Compute the inverse cumulative distribution function at u.
- Parameters:
u (
Union[int,float,StochasticScalar]) – Single probability or sequence of probabilities to evaluate.- Return type:
Union[int,float,StochasticScalar]- Returns:
Quantile value(s) - same type as input (Numeric -> Numeric, Sequence -> Sequence).
- class pal.distributions.GEV(shape, scale, loc=0.0)[source]
Bases:
DistributionBaseGeneralized Extreme Value Distribution.
The cumulative distribution function (CDF) is:
\[\begin{split}F(x) = \begin{cases} \exp\left[-\left(1 + \xi\frac{x-\mu}{\sigma}\right)^{-1/\xi}\right] & \text{for } \xi \neq 0 \\ \exp\left[-\exp\left(-\frac{x-\mu}{\sigma}\right)\right] & \text{for } \xi = 0 \end{cases}\end{split}\]where \(\xi\) is the shape parameter, \(\sigma > 0\) is the scale parameter, and \(\mu\) is the location parameter.
The GEV distribution unifies the Gumbel (\(\xi = 0\)), Fréchet (\(\xi > 0\)), and Weibull (\(\xi < 0\)) families. Essential for extreme value analysis in catastrophe modeling.
- Parameters:
shape (
Union[int,float,StochasticScalar]) – Shape parameter \(\xi\).scale (
Union[int,float,StochasticScalar]) – Scale parameter \(\sigma\).loc (
Union[int,float,StochasticScalar]) – Location parameter \(\mu\) (default 0).
- __init__(shape, scale, loc=0.0)[source]
Initialize GEV distribution.
- Parameters:
shape (
Union[int,float,StochasticScalar]) – Shape parameter.scale (
Union[int,float,StochasticScalar]) – Scale parameter.loc (
Union[int,float,StochasticScalar]) – Location parameter.
- cdf(x)[source]
Compute cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- invcdf(u)[source]
Compute inverse cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.StudentsT(nu, mu=0.0, sigma=1.0)[source]
Bases:
DistributionBaseStudent’s t Distribution.
The cumulative distribution function (CDF) is:
\[F(x) = \frac{1}{2} + \frac{x\Gamma\left(\frac{\nu+1}{2}\right)} {\sqrt{\pi\nu}\Gamma\left(\frac{\nu}{2}\right)} \,_2F_1\left(\frac{1}{2}, \frac{\nu+1}{2}; \frac{3}{2}; -\frac{x^2}{\nu}\right)\]where \(\nu > 0\) is the degrees of freedom parameter, \(\Gamma\) is the gamma function, and \(_2F_1\) is the hypergeometric function.
For the non-standardized version with location \(\mu\) and scale \(\sigma\), substitute \(x \to (x-\mu)/\sigma\).
The Student’s t distribution has heavier tails than the normal distribution, making it useful for modeling extreme events in financial and operational risk.
- Parameters:
nu (
Union[int,float,StochasticScalar]) – Degrees of freedom \(\nu\).mu (
Union[int,float,StochasticScalar]) – Location parameter \(\mu\) (default 0).sigma (
Union[int,float,StochasticScalar]) – Scale parameter \(\sigma\) (default 1).
- __init__(nu, mu=0.0, sigma=1.0)[source]
Initialize Student’s t distribution.
- Parameters:
nu (
Union[int,float,StochasticScalar]) – Degrees of freedom.mu (
Union[int,float,StochasticScalar]) – Location parameter.sigma (
Union[int,float,StochasticScalar]) – Scale parameter.
- cdf(x)[source]
Compute cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- invcdf(u)[source]
Compute inverse cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.InverseGaussian(mu, lambda_)[source]
Bases:
DistributionBaseInverse Gaussian (Wald) Distribution.
The cumulative distribution function (CDF) is:
\[F(x) = \Phi\left(\sqrt{\frac{\lambda}{x}} \left(\frac{x}{\mu}-1\right)\right) + \exp\left(\frac{2\lambda}{\mu}\right) \Phi\left(-\sqrt{\frac{\lambda}{x}} \left(\frac{x}{\mu}+1\right)\right)\]where \(\Phi\) is the standard normal CDF, \(\mu > 0\) is the mean parameter, and \(\lambda > 0\) is the shape parameter.
The inverse Gaussian distribution is widely used in operational risk modeling (Basel II) and for first passage time problems.
- Parameters:
mu (
Union[int,float,StochasticScalar]) – Mean parameter \(\mu\).lambda – Shape parameter \(\lambda\).
- __init__(mu, lambda_)[source]
Initialize inverse Gaussian distribution.
- Parameters:
mu (
Union[int,float,StochasticScalar]) – Mean parameter.lambda – Shape parameter.
- cdf(x)[source]
Compute cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- invcdf(u)[source]
Compute inverse cumulative distribution function.
Uses numerical root finding since there is no closed form.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.Exponential(scale, loc=0.0)[source]
Bases:
DistributionBaseExponential Distribution.
The cumulative distribution function (CDF) is:
\[F(x) = 1 - \exp\left(-\frac{x-\mu}{\sigma}\right), \quad x > \mu\]where \(\sigma > 0\) is the scale parameter (mean) and \(\mu\) is the location parameter.
The exponential distribution is memoryless and commonly used to model waiting times.
- Parameters:
scale (
Union[int,float,StochasticScalar]) – Scale parameter \(\sigma\).loc (
Union[int,float,StochasticScalar]) – Location parameter \(\mu\) (default 0).
- __init__(scale, loc=0.0)[source]
Initialize exponential distribution.
- Parameters:
scale (
Union[int,float,StochasticScalar]) – Scale parameter.loc (
Union[int,float,StochasticScalar]) – Location parameter.
- cdf(x)[source]
Compute the cumulative distribution function at x.
- Parameters:
x (
Union[int,float,StochasticScalar]) – Single value or sequence of values to evaluate.- Return type:
Union[int,float,StochasticScalar]- Returns:
CDF value(s) - same type as input (Numeric -> Numeric, Sequence -> Sequence).
- invcdf(u)[source]
Compute the inverse cumulative distribution function at u.
- Parameters:
u (
Union[int,float,StochasticScalar]) – Single probability or sequence of probabilities to evaluate.- Return type:
Union[int,float,StochasticScalar]- Returns:
Quantile value(s) - same type as input (Numeric -> Numeric, Sequence -> Sequence).
- class pal.distributions.Uniform(a, b)[source]
Bases:
DistributionBaseUniform Distribution.
- Defined by:
F(x) = (x - a) / (b - a), for a <= x <= b
- cdf(x)[source]
Compute cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- invcdf(u)[source]
Compute inverse cumulative distribution function.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.InverseExponential(scale, loc=0)[source]
Bases:
DistributionBaseInverse Exponential Distribution.
The cumulative distribution function (CDF) is:
\[F(x) = \exp\left(-\frac{\sigma}{x-\mu}\right), \quad x > \mu\]where \(\sigma > 0\) is the scale parameter and \(\mu\) is the location parameter.
- cdf(x)[source]
Compute the cumulative distribution function at x.
- Parameters:
x (
Union[int,float,StochasticScalar]) – Single value or sequence of values to evaluate.- Return type:
Union[int,float,StochasticScalar]- Returns:
CDF value(s) - same type as input (Numeric -> Numeric, Sequence -> Sequence).
- invcdf(u)[source]
Compute the inverse cumulative distribution function at u.
- Parameters:
u (
Union[int,float,StochasticScalar]) – Single probability or sequence of probabilities to evaluate.- Return type:
Union[int,float,StochasticScalar]- Returns:
Quantile value(s) - same type as input (Numeric -> Numeric, Sequence -> Sequence).
- class pal.distributions.DistributionGeneratorBase(distribution)[source]
Bases:
objectBase class for parameterized distribution generators.
Wraps a DistributionBase instance.
- __init__(distribution)[source]
Initialize distribution generator with a distribution instance.
- Parameters:
distribution (
DistributionBase) – The distribution to wrap.
- cdf(x)[source]
Delegate to wrapped distribution.
- Return type:
Union[int,float,StochasticScalar]
- invcdf(u)[source]
Delegate to wrapped distribution.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.DiscreteDistributionGenerator(distribution_name, parameters)[source]
Bases:
DistributionGeneratorBaseDiscrete distribution generator instantiated by name.
- __init__(distribution_name, parameters)[source]
Initialize discrete distribution by name.
- Parameters:
distribution_name (
str) – Name of the discrete distribution.parameters (
list[Union[int,float,StochasticScalar]]) – Distribution parameters.
- cdf(x)
Delegate to wrapped distribution.
- Return type:
Union[int,float,StochasticScalar]
- generate(n_sims=None, rng=None)
Delegate to wrapped distribution.
- Parameters:
- Return type:
- invcdf(u)
Delegate to wrapped distribution.
- Return type:
Union[int,float,StochasticScalar]
- class pal.distributions.ContinuousDistributionGenerator(distribution_name, parameters)[source]
Bases:
DistributionGeneratorBaseContinuous distribution generator instantiated by name.
- __init__(distribution_name, parameters)[source]
Initialize continuous distribution by name.
- Parameters:
distribution_name (
str) – Name of the continuous distribution.parameters (
list[Union[int,float,StochasticScalar]]) – Distribution parameters.
- cdf(x)
Delegate to wrapped distribution.
- Return type:
Union[int,float,StochasticScalar]
- generate(n_sims=None, rng=None)
Delegate to wrapped distribution.
- Parameters:
- Return type:
- invcdf(u)
Delegate to wrapped distribution.
- Return type:
Union[int,float,StochasticScalar]
Available Distributions
The following distributions are available:
Gamma: Gamma distribution for modeling losses
LogNormal: Log-normal distribution
Normal: Normal (Gaussian) distribution
Uniform: Uniform distribution
Beta: Beta distribution
Exponential: Exponential distribution
Weibull: Weibull distribution
Pareto: Pareto distribution
All distributions follow a similar API pattern and support GPU acceleration when enabled.