Univariate Distributions
Support Handling
Univariate distributions enforce support-aware outputs:
logpdf(x)returns-infoutside support.cdf(x)returns0below support and1above support.fitting uses a penalized objective that discourages invalid parameter regions and non-finite likelihood contributions.
Univariate probability distributions and fitting utilities.
Distribution Objects
File containing the copulAX implementation of the normal distribution.
- class copulax._src.univariate.normal.Normal(name='Normal', *, mu=None, sigma=None)[source]
The normal / Gaussian distribution is a continuous ‘bell shaped’ 2 parameter family.
The normal distribution is defined as:
\[f(x|\mu, \sigma) = \frac{1}{\sqrt{2\pi\sigma^2}} \exp\left(-\frac{(x - \mu)^2}{2\sigma^2}\right)\]where \(\mu\) is the mean and \(\sigma\) the standard deviation of the data.
https://en.wikipedia.org/wiki/Normal_distribution
- example_params(*args, **kwargs)[source]
Example parameters for the normal distribution.
This is a two parameter family, with the normal / gaussian being defined by its mean and standard deviation.
File containing the copulAX implementation of the student-T distribution.
- class copulax._src.univariate.student_t.StudentT(name='Student-T', *, nu=None, mu=None, sigma=None)[source]
The Student’s t distribution is a three-parameter continuous family that generalises the normal by allowing heavier tails; as \(\nu \to \infty\) the density converges to the normal. The location-scale form adopted here is standard in quantitative finance (McNeil et al 2005).
The PDF is
\[f(x | \nu, \mu, \sigma) = \frac{\Gamma\!\left((\nu + 1)/2\right)} {\sqrt{\nu \pi}\, \sigma\, \Gamma(\nu / 2)} \left(1 + \frac{1}{\nu}\left(\frac{x - \mu}{\sigma}\right)^2\right)^{-(\nu + 1)/2}\]where \(\nu > 0\) is the degrees of freedom (controlling tail weight; the \(k\)-th moment exists only for \(k < \nu\)), \(\mu \in \mathbb{R}\) is the location, and \(\sigma > 0\) is the scale.
https://en.wikipedia.org/wiki/Student%27s_t-distribution
- example_params(*args, **kwargs)[source]
Returns example parameters for the distribution.
- Returns:
A dictionary containing example distribution parameters.
- Return type:
- rvs(size, params=None, key=None)[source]
Generate random variates from the Student-T distribution.
- Parameters:
- Return type:
- Returns:
Array of random samples.
- fit(x, method='ldmle', lr=0.1, maxiter=100, name=None)[source]
Fit the distribution to the input data via numerical MLE.
Note
If you intend to jit wrap this function, ensure that
methodis a static argument.- Parameters:
x (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – The input data to fit the distribution to.method (
str) – The fitting method to use. One of:'mle'— full maximum likelihood estimation;'ldmle'— low-dimensional maximum likelihood estimation. Defaults to'ldmle'.lr (
float) – Learning rate for the fitting process.maxiter (
int) – Maximum number of iterations for the fitting process.name (
str) – Optional custom name for the fitted instance.
- Returns:
A fitted
StudentTinstance.- Return type:
- Raises:
ValueError – If
methodis not one of the accepted strings listed above.
File containing the copulAX implementation of the continuous uniform distribution.
- class copulax._src.univariate.uniform.Uniform(name='Uniform', *, a=None, b=None)[source]
The continuous uniform distribution.
The continuous uniform distribution is defined as:
\[f(x|a, b) = \frac{1}{b - a}\]where \(a\) is the lower bound of the distribution and \(b\) is the upper bound.
- example_params(*args, **kwargs)[source]
Returns example parameters for the distribution.
- Returns:
A dictionary containing example distribution parameters.
- Return type:
- logpdf(x, params=None)[source]
Compute the log probability density function.
Returns
log(1 / (b - a))inside the support,-infoutside.
- rvs(size, params=None, key=None)[source]
Generate random variates from the uniform distribution.
- Parameters:
- Return type:
- Returns:
Array of random samples in
[a, b).
- stats(params=None)[source]
Compute distribution statistics (mean, median, variance, std, skewness, kurtosis).
File containing the copulAX implementation of the Gamma distribution.
- class copulax._src.univariate.gamma.Gamma(name='Gamma', *, alpha=None, beta=None)[source]
The gamma distribution is a two-parameter continuous family on \((0, \infty)\) that includes the exponential, Erlang, and chi-squared distributions as special cases. The rate parameterisation of McNeil et al (2005) is used.
The PDF is
\[f(x | \alpha, \beta) = \frac{\beta^{\alpha}}{\Gamma(\alpha)}\, x^{\alpha - 1} e^{-\beta x}, \qquad x > 0\]where \(\alpha > 0\) is the shape parameter and \(\beta > 0\) is the rate parameter (so the mean is \(\alpha / \beta\)).
https://en.wikipedia.org/wiki/Gamma_distribution
- example_params(*args, **kwargs)[source]
Returns example parameters for the distribution.
- Returns:
A dictionary containing example distribution parameters.
- Return type:
- stats(params=None)[source]
Compute distribution statistics (mean, mode, variance, std, skewness, kurtosis).
File containing the copulAX implementation of the exponential distribution.
- class copulax._src.univariate.exponential.Exponential(name='Exponential', *, lamb=None)[source]
The exponential distribution is a continuous distribution that describes the time between events in a Poisson process.
The exponential distribution is defined as:
\[f(x|\lambda) = \lambda e^{-\lambda x}\]where \(\lambda\) is the rate parameter of the distribution.
https://en.wikipedia.org/wiki/Exponential_distribution
- Parameters:
lamb (Array)
- example_params(*args, **kwargs)[source]
Return example parameters for the distribution.
This is a single parameter family defined by the rate parameter lambda.
- Return type:
- rvs(size, params=None, key=None)[source]
Generate random variates from the exponential distribution via inverse transform sampling.
File containing the copulAX implementation of the lognormal distribution.
- class copulax._src.univariate.lognormal.LogNormal(name='LogNormal', *, mu=None, sigma=None)[source]
The log-normal distribution on \((0, \infty)\) describes a positive variate \(X\) whose logarithm \(Y = \log X\) is normally distributed with mean \(\mu\) and standard deviation \(\sigma\). Two-parameter continuous family.
The PDF is
\[f(x | \mu, \sigma) = \frac{1}{x \sigma \sqrt{2\pi}} \exp\!\left(-\frac{(\log x - \mu)^2}{2 \sigma^2}\right), \qquad x > 0\]where \(\mu \in \mathbb{R}\) and \(\sigma > 0\) are the mean and standard deviation of the underlying normal \(\log X\) (not of \(X\) itself; the mean of \(X\) is \(\exp(\mu + \sigma^2 / 2)\)).
https://en.wikipedia.org/wiki/Log-normal_distribution
- example_params(*args, **kwargs)[source]
Returns example parameters for the distribution.
- Returns:
A dictionary containing example distribution parameters.
- Return type:
- stats(params=None)[source]
Compute distribution statistics (mean, median, mode, variance, std, skewness, kurtosis).
File containing the copulAX implementation of the Inverse Gamma distribution.
- class copulax._src.univariate.ig.IG(name='IG', *, alpha=None, beta=None)[source]
The inverse gamma distribution is a two-parameter continuous family on \((0, \infty)\) describing the reciprocal of a gamma-distributed variate. The parameterisation matches McNeil et al (2005) and is consistent with
Gamma: if \(X \sim \text{Gamma}(\alpha, \beta)\) under the rate parameterisation used here, then \(1 / X \sim \text{IG}(\alpha, \beta)\) with the same \(\beta\) value.The PDF is
\[f(x | \alpha, \beta) = \frac{\beta^{\alpha}}{\Gamma(\alpha)}\, x^{-\alpha - 1} e^{-\beta / x}, \qquad x > 0\]where \(\alpha > 0\) is the shape parameter and \(\beta > 0\) enters the kernel as \(\exp(-\beta / x)\) — i.e. a scale parameter in \(x\)’s own units. The mean is \(\beta / (\alpha - 1)\) for \(\alpha > 1\).
https://en.wikipedia.org/wiki/Inverse-gamma_distribution
- example_params(*args, **kwargs)[source]
Returns example parameters for the distribution.
- Returns:
A dictionary containing example distribution parameters.
- Return type:
- rvs(size, params=None, key=None)[source]
Generate random variates as the reciprocal of Gamma variates.
- stats(params=None)[source]
Compute distribution statistics.
Returns NaN for moments that are undefined given the current alpha.
File containing the copulAX implementation of the Generalized Inverse Gaussian distribution.
- class copulax._src.univariate.gig.GIG(name='GIG', *, lamb=None, chi=None, psi=None)[source]
The Generalized Inverse Gaussian distribution is a three-parameter continuous family on \((0, \infty)\) that arises as the mixing distribution of the generalised hyperbolic family. The inverse-gamma, gamma, and inverse-Gaussian distributions are special / limiting cases. The McNeil et al (2005) parameterisation is used.
The PDF is
\[f(x | \lambda, \chi, \psi) = \frac{(\psi / \chi)^{\lambda / 2}} {2\, K_{\lambda}\!\bigl(\sqrt{\chi \psi}\bigr)}\, x^{\lambda - 1} \exp\!\left(-\tfrac{1}{2}(\chi / x + \psi x)\right), \qquad x > 0\]where \(K_{\lambda}\) is the modified Bessel function of the second kind, \(\lambda \in \mathbb{R}\) is the shape / order parameter, \(\chi > 0\) is the concentration (or penalty on small \(x\)), and \(\psi > 0\) is the rate (penalty on large \(x\)).
https://en.wikipedia.org/wiki/Generalized_inverse_Gaussian_distribution
- example_params(*args, **kwargs)[source]
Returns example parameters for the distribution.
- Returns:
A dictionary containing example distribution parameters.
- Return type:
- rvs(size, params=None, key=None)[source]
Generate random variates using the Devroye (2014) rejection algorithm.
- Parameters:
- Return type:
- Returns:
Array of GIG random samples.
- stats(params=None)[source]
Compute distribution statistics (mean, variance, std, mode).
Uses analytical formulas based on modified Bessel functions. Falls back to sample estimates when numerical instability causes NaN.
File containing the copulAX implementation of the Generalized normal distribution.
- class copulax._src.univariate.gen_normal.GenNormal(name='GenNormal', *, mu=None, alpha=None, beta=None)[source]
The symmetric generalized normal distribution is a three-parameter continuous family that generalises the normal by allowing heavier or lighter tails. The normal (
beta = 2) and Laplace (beta = 1) distributions arise as special cases; asbeta -> infthe density tends to a uniform on[mu - alpha, mu + alpha].The PDF is
\[f(x | \mu, \alpha, \beta) = \frac{\beta}{2 \alpha \, \Gamma(1/\beta)} \exp\!\left(-\left(\frac{|x - \mu|}{\alpha}\right)^\beta\right)\]where \(\mu \in \mathbb{R}\) is the location, \(\alpha > 0\) is the scale, and \(\beta > 0\) is the shape parameter controlling tail weight.
https://en.wikipedia.org/wiki/Generalized_normal_distribution
- example_params(*args, **kwargs)[source]
Returns example parameters for the distribution.
- Returns:
A dictionary containing example distribution parameters.
- Return type:
- cdf(x, params=None)[source]
Cumulative distribution function of the distribution.
- Parameters:
- Returns:
The cdf values.
- Return type:
- rvs(size, params=None, key=None)[source]
Generates random samples from the distribution.
Note
If you intend to jit wrap this function, ensure that ‘size’ is a static argument.
- Parameters:
size (
Union[tuple,float,int,Array,ndarray,bool,number,bool,complex]) – The size / shape of the generated output array of random numbers. If a scalar is provided, the output array will have shape (size,), otherwise it will match the shape specified by this tuple.params (
dict) – Parameters describing the distribution. See the specific distribution class or the ‘example_params’ method for details.key (
Array) – The Key for random number generation.
- Return type:
- fit(x, method='mle', name=None)[source]
Fit the distribution to data.
Note
If you intend to jit wrap this function, ensure that
methodis a static argument.- Parameters:
x (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – Input data to fit.method (
str) – Fitting method. One of:'mle'— MLE algorithm using Brent’s method (derivative-free numerical root-finding; default);'mom'— closed-form method of moments (faster, no μ refinement step).name (
str) – Optional custom name for the fitted instance.
- Returns:
A fitted
GenNormalinstance.- Return type:
- Raises:
ValueError – If
methodis not one of the accepted strings listed above.
File containing the copulAX implementation of the Asymmetric Generalized Normal distribution.
- class copulax._src.univariate.asym_gen_normal.AsymGenNormal(name='AsymGenNormal', *, zeta=None, alpha=None, kappa=None)[source]
The asymmetric generalized normal distribution is a three-parameter continuous family that adds skewness to the normal via a log-link transformation of a standard normal variate \(X = \zeta + \alpha (1 - e^{-\kappa Z}) / \kappa\). The normal (
kappa = 0) arises as the limiting symmetric case.The PDF is
\[\begin{split}f(x | \zeta, \alpha, \kappa) = \frac{\phi(y)}{\alpha - \kappa (x - \zeta)}, \qquad y = \begin{cases} (x - \zeta) / \alpha, & \kappa = 0 \\ -\,\kappa^{-1} \log\!\left(1 - \kappa (x - \zeta) / \alpha\right), & \kappa \ne 0 \end{cases}\end{split}\]where \(\phi\) is the standard-normal PDF, \(\zeta \in \mathbb{R}\) is the location, \(\alpha > 0\) is the scale, and \(\kappa \in \mathbb{R}\) is the shape parameter controlling skewness (positive \(\kappa\) skews left, negative right). The support is right-bounded when \(\kappa > 0\) and left-bounded when \(\kappa < 0\).
https://en.wikipedia.org/wiki/Generalized_normal_distribution
- example_params(*args, **kwargs)[source]
Returns example parameters for the distribution.
- Returns:
A dictionary containing example distribution parameters.
- Return type:
- rvs(size, params=None, key=None)[source]
Generate random variates via transformation of standard normals.
- stats(params=None)[source]
Compute distribution statistics (mean, median, mode, variance, skewness, kurtosis).
- fit(x, method='mle', lr=0.1, maxiter=100, name=None)[source]
Fit the distribution to data.
Note
If you intend to jit wrap this function, ensure that
methodis a static argument.- Parameters:
x (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – Input data to fit.method (
str) – Fitting method. One of:'mle'— projected-gradient maximum likelihood with MoM initialisation (numerical; default);'mom'— closed-form method of moments (faster, no gradient refinement).lr (
float) – Learning rate for optimisation (MLE only; ignored for'mom'). Default0.1.maxiter (
int) – Maximum number of iterations (MLE only; ignored for'mom').name (
str) – Optional custom name for the fitted instance.
- Returns:
A fitted
AsymGenNormalinstance.- Return type:
- Raises:
ValueError – If
methodis not one of the accepted strings listed above.
File containing the copulAX implementation of the skewed-T distribution.
- class copulax._src.univariate.skewed_t.SkewedT(name='Skewed-T', *, nu=None, mu=None, sigma=None, gamma=None)[source]
The skewed-t distribution is a four-parameter continuous generalisation of the Student’s t that admits asymmetry via a mean-variance mixture of normals with an inverse-gamma mixing variable. It arises as the limiting case of the generalised hyperbolic distribution with \(\psi \to 0\) and \(\lambda = -\nu/2\), and collapses to the symmetric Student’s t at \(\gamma = 0\). The four-parameter McNeil et al (2005) specification is used.
The PDF is
\[ \begin{align}\begin{aligned}f(x | \nu, \mu, \sigma, \gamma) = \frac{2^{1 - s}}{\Gamma(\nu/2)\,\sqrt{\nu \pi}\,\sigma}\; K_s(r)\, r^{s}\, \frac{\exp\!\bigl(\gamma (x - \mu) / \sigma^2\bigr)} {\bigl(1 + Q/\nu\bigr)^{s}},\\\qquad s = \frac{\nu + 1}{2}, \quad Q = \frac{(x - \mu)^2}{\sigma^2}, \quad r = \sqrt{(\nu + Q)\, \gamma^2 / \sigma^2}\end{aligned}\end{align} \]where \(K_s\) is the modified Bessel function of the second kind, \(\nu > 0\) is the degrees of freedom, \(\mu \in \mathbb{R}\) is the location, \(\sigma > 0\) is the scale, and \(\gamma \in \mathbb{R}\) is the skewness parameter.
https://en.wikipedia.org/wiki/Skew-t_distribution
- example_params(*args, **kwargs)[source]
Returns example parameters for the distribution.
- Returns:
A dictionary containing example distribution parameters.
- Return type:
- rvs(size, params=None, key=None)[source]
Generate random variates via mean-variance mixture of normals.
- stats(params=None)[source]
Compute distribution statistics derived from the mean-variance mixture representation.
- fit(x, method='em', lr=0.1, maxiter=100, name=None)[source]
Fit the distribution to the input data via numerical MLE.
Note
If you intend to jit wrap this function, ensure that
methodis a static argument.- Parameters:
x (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – The input data to fit the distribution to.method (
str) – The fitting method to use. One of:'em'— the ECME algorithm (McNeil et al. 2005);'mle'— projected-gradient maximum likelihood;'ldmle'— low-dimensional maximum likelihood estimation. Defaults to'em'.lr (float) – Learning rate for the optimiser.
maxiter (
int) – Maximum number of iterations for the optimiser.name (
str) – Optional custom name for the fitted instance.
- Returns:
A fitted
SkewedTinstance.- Return type:
- Raises:
ValueError – If
methodis not one of the accepted strings listed above.
File containing the copulAX implementation of the generalized hyperbolic distribution.
- class copulax._src.univariate.gh.GH(name='GH', *, lamb=None, chi=None, psi=None, mu=None, sigma=None, gamma=None)[source]
The generalized hyperbolic distribution. This is a flexible, continuous 6-parameter family of distributions that can model a variety of data behaviors, including heavy tails and skewness. It contains a number of popular distributions as special cases, including the normal, student-t, hyperbolic, laplace, and skewed-T distributions.
We adopt the parameterization used by McNeil et al. (2005):
\[f(x|\mu, \sigma, \chi, \psi, \gamma, \lambda) \propto e^{\gamma (x-\mu) / \sigma^2}\, \frac{K_{\lambda - 0.5}(\sqrt{A})} {(\sqrt{A})^{0.5 - \lambda}}, \qquad A = \left(\chi + \left(\tfrac{x-\mu}{\sigma}\right)^2\right) \left(\psi + \left(\tfrac{\gamma}{\sigma}\right)^2\right)\]where \(K_{\lambda}\) is the modified Bessel function of the second kind, \(\mu\) is the location parameter, \(\sigma\) is the scale, \(\gamma\) is the skewness and \(\lambda\), \(\chi\) and \(\psi\) relate to the shape of the distribution.
- example_params(*args, **kwargs)[source]
Returns example parameters for the distribution.
- Returns:
A dictionary containing example distribution parameters.
- Return type:
- rvs(size, params=None, key=None)[source]
Generate random variates via GIG-normal mean-variance mixture.
- stats(params=None)[source]
Compute distribution statistics derived from the GIG-normal mixture representation.
- fit(x, method='em', lr=0.1, maxiter=100, name=None)[source]
Fit the distribution to the input data via numerical MLE.
Note
If you intend to jit wrap this function, ensure that
methodis a static argument.- Parameters:
x (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – The input data to fit the distribution to.method (
str) – The fitting method to use. One of:'em'— the ECME algorithm (McNeil et al. 2005);'mle'— direct projected-gradient maximum likelihood;'ldmle'— low-dimensional maximum likelihood estimation. Defaults to'em'.lr (
float) – Learning rate for the optimiser.maxiter (
int) – Maximum number of iterations for the optimiser.name (
str) – Optional custom name for the fitted instance.
- Returns:
A fitted
GHinstance.- Return type:
- Raises:
ValueError – If
methodis not one of the accepted strings listed above.
File containing the copulAX implementation of the Normal-Inverse Gaussian distribution.
- class copulax._src.univariate.nig.NIG(name='NIG', *, mu=None, alpha=None, beta=None, delta=None)[source]
The Normal-Inverse Gaussian distribution. This is a flexible, continuous 4-parameter distribution that can capture skewness and heavy tails. It is a special case of the Generalized Hyperbolic distribution, obtained by fixing \(\lambda = -\tfrac{1}{2}\).
We adopt the parameterization used on Wikipedia (and by Karlis 2002):
\[f(x|\mu, \alpha, \beta, \delta) = \frac{\alpha \delta K_{1}\left(\alpha \sqrt{\delta^2 + (x-\mu)^2}\right)} {\pi \sqrt{\delta^2 + (x-\mu)^2}} e^{\delta \sqrt{\alpha^2 - \beta^2} + \beta (x-\mu)}\]where \(K_{1}\) is the modified Bessel function of the second kind of order 1, \(\mu \in \mathbb{R}\) is the location parameter, \(\delta > 0\) is the scale parameter, \(\alpha > 0\) controls the tail heaviness, and \(\beta \in (-\alpha, \alpha)\) controls the asymmetry / skewness.
- example_params(*args, **kwargs)[source]
Returns example parameters for the distribution.
- Returns:
A dictionary containing example distribution parameters.
- Return type:
- rvs(size, params=None, key=None)[source]
Generate random variates via an IG-normal variance-mean mixture.
- fit(x, method='em', lr=0.1, maxiter=100, name=None)[source]
Fit the NIG distribution to the input data.
Note
If you intend to
jit-wrap this function, ensure thatmethodis a static argument.- Parameters:
x (
Union[Array,ndarray,bool,number,bool,int,float,complex]) – The input data to fit the distribution to.method (
str) – Fitting method. One of:'em'— iterated Karlis (2002) EM step (numerical; default);'mle'— 3-parameter projected-gradient MLE via the exact β-score identity (numerical);'mom'— closed-form method of moments.lr (
float) – Learning rate for the projected-gradient MLE. Ignored for'em'and'mom'.maxiter (
int) – Maximum number of iterations for iterative methods. Ignored for'mom'.name (
str) – Optional custom name for the fitted instance.
- Returns:
A fitted
NIGinstance.- Return type:
- Raises:
ValueError – If
methodis not one of the accepted strings listed above.
File containing the copulAX implementation of the Wald/Inverse Gaussian distribution.
- class copulax._src.univariate.wald.Wald(name='Wald', *, mu=None, lamb=None)[source]
The Wald distribution, also known as the Inverse Gaussian distribution, is a continuous 2 parameter family.
The Wald distribution is defined as:
\[f(x|\mu, \lambda) = \sqrt{\frac{\lambda}{2\pi x^3}} \exp\left(-\frac{\lambda(x-\mu)^2}{2\mu^2 x}\right)\]where \(\mu\) is the mean and \(\lambda\) the shape parameter of the distribution.
https://en.wikipedia.org/wiki/Inverse_Gaussian_distribution
- example_params(*args, **kwargs)[source]
Return example parameters for the Wald / Inverse Gaussian distribution.
- Return type:
- logpdf(x, params=None)[source]
Compute the log probability density function of the Wald distribution.
- Parameters:
- Return type:
- Returns:
Log-PDF values with the same shape as
x.
- cdf(x, params=None)[source]
Compute the cumulative distribution function of the Wald / Inverse Gaussian distribution.
- rvs(size, params=None, key=None)[source]
Generate random variates from the Wald distribution via Michael-Schucany-Haas.
- stats(params=None)[source]
Compute the mean and variance of the Wald distribution given its parameters.
Fitting Utilities
contains the copulAX implementation of a univariate fitter object.
- copulax._src.univariate.univariate_fitter.univariate_fitter(x, metric='bic', distributions='common continuous', gof_test=None, significance_level=0.05)[source]
Find and fit the ‘best’ univariate distribution to the input data according to a specified metric.
The implementation is fully JIT-compiled: a single
jax.jit-traced function fits every registered distribution vialax.switch, computes the chosen metric, optionally applies a goodness-of-fit filter, and sorts the results — all on-device in one XLA graph. After the first call the compiled graph is cached, so subsequent calls (e.g. once per marginal variable in a copula) execute at near-zero Python overhead.- Parameters:
x (
Array) – The input data to fit a distribution to.metric (
str) – The metric to use when selecting the ‘best’ distribution. Must be one of ‘aic’, ‘bic’ or ‘loglikelihood’. Default is ‘bic’.distributions (
Union[Iterable,str]) – The distribution(s) to fit to the data. If a string, must be one of ‘all’, ‘common’, ‘continuous’, ‘discrete’, ‘common continuous’ or ‘common discrete’. If an iterable, must contain copulAX distribution objects. Default is ‘common continuous’.gof_test (
str|None) – Optional goodness-of-fit test to apply after fitting. One of ‘ks’ (Kolmogorov-Smirnov), ‘cvm’ (Cramér-von Mises), or None (no test). When set, distributions that fail the test at the given significance_level are removed from the results. Default is None.significance_level (
float) – Significance level for the goodness-of-fit test. Distributions with a p-value below this threshold are removed. Only used when gof_test is not None. Default is 0.05.
- Returns:
The index of the best distribution fit (always 0) and a tuple of fitted distribution results sorted by the metric (best first). Each result is a dict with keys ‘params’, ‘metric’, ‘dist’, and optionally ‘gof’. Returns
(None, ())if all distributions are filtered out by the goodness-of-fit test.- Return type:
Examples: >>> import jax.numpy as jnp >>> import numpy as np >>> from copulax.univariate import univariate_fitter >>> x = np.random.normal(0, 1, 100) >>> univariate_fitter(x) >>> univariate_fitter(x, gof_test=’ks’, significance_level=0.05)
- copulax._src.univariate.univariate_fitter.batch_univariate_fitter(x, metric='bic', distributions='common continuous', gof_test=None, significance_level=0.05)[source]
Fit univariate distributions to every column of x simultaneously.
Equivalent to calling
univariate_fitter()on each column, but usesjax.vmapto process all columns in a single device call, which is significantly faster for multi-dimensional data.- Parameters:
x (
Array) – Input data of shape(n, d).metric (
str) – Selection metric —'aic','bic', or'loglikelihood'. Default'bic'.distributions (
Union[Iterable,str]) – Distributions to try (same asunivariate_fitter()).gof_test (
str|None) – Optional goodness-of-fit test ('ks','cvm', orNone).significance_level (
float) – GoF p-value threshold (default 0.05).
- Returns:
One
(best_index, fitted)tuple per column, in the same format asunivariate_fitter().- Return type:
Goodness of Fit
JAX-jittable goodness-of-fit tests for univariate distributions.
Implements the Kolmogorov-Smirnov and Cramér-von Mises one-sample tests. Both test statistics and asymptotic p-values are fully jit-compilable.
- copulax._src.univariate._gof.ks_test(x, dist, params)[source]
One-sample Kolmogorov-Smirnov goodness-of-fit test.
Tests whether x was drawn from the distribution described by dist and params.