Distribution utilities#

Created on Aug 03 17:13:21 2024

The utilities_d module serves as a cornerstone of the pyMultiFit library, containing majority of the core utility functions utilized across various classes and components. It provides a comprehensive suite of mathematical and statistical tools, including probability distribution functions (PDFs), cumulative distribution functions (CDFs), some internal scaling and masking utilities, and data preprocessing methods.

Available for user#

arc_sine_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute PDF of ArcSineDistribution.

Parameters:
xnp.ndarray

Input array of values where PDF is evaluated.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

locfloat, optional

The location parameter specifying the lower bound of the distribution. Defaults to 0.0.

scalefloat, optional

The scale parameter, specifying the width of the distribution. Defaults to 1.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The ArcSine PDF is defined as:

\[f(y) = \frac{1}{\pi \sqrt{y(1-y)}}\]

where, \(y\) is the transformed value of \(x\), defined as:

\[y = \frac{x - \text{loc}}{\text{scale}}\]

The final PDF is expressed as \(f(y)/\text{scale}\).

arc_sine_log_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute logPDF of ArcSineDistribution.

Parameters:
xnp.ndarray

Input array of values where PDF is evaluated.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

locfloat, optional

The location parameter specifying the lower bound of the distribution. Defaults to 0.0.

scalefloat, optional

The scale parameter, specifying the width of the distribution. Defaults to 1.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The ArcSine logPDF is defined as:

\[\ell(y) = -\ln(\pi) - 0.5\ln(y-y^2)\]

where, \(y\) is the transformed value of \(x\), defined as:

\[y = \frac{x - \text{loc}}{\text{scale}}\]

The final logPDF is expressed as \(\ell(y) - \ln(\text{scale})\).

arc_sine_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute PDF of ArcSineDistribution.

Parameters:
xnp.ndarray

Input array of values where PDF is evaluated.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

locfloat, optional

The location parameter specifying the lower bound of the distribution. Defaults to 0.0.

scalefloat, optional

The scale parameter, specifying the width of the distribution. Defaults to 1.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The ArcSine PDF is defined as:

\[f(y) = \frac{1}{\pi \sqrt{y(1-y)}}\]

where, \(y\) is the transformed value of \(x\), defined as:

\[y = \frac{x - \text{loc}}{\text{scale}}\]

The final PDF is expressed as \(f(y)/\text{scale}\).

arc_sine_log_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log CDF of ArcSineDistribution.

Parameters:
xnp.ndarray

Input array of values where PDF is evaluated.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

locfloat, optional

The location parameter specifying the lower bound of the distribution. Defaults to 0.0.

scalefloat, optional

The scale parameter, specifying the width of the distribution. Defaults to 1.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The ArcSine log CDF is defined as:

\[\mathcal{L}(y) = \ln\left(\frac{2}{\pi}\right) + \ln\arcsin(\sqrt{y})\]

where \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{x - \text{loc}}{\text{scale}}\]

The final logCDF is expressed as \(\mathcal{L}(y)\).

beta_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, alpha: float = 1.0, beta_: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute PDF of BetaDistribution.

Parameters:
beta_
xnp.ndarray

Input array of values where PDF is evaluated.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

alphafloat, optional

The \(\alpha\) parameter. Default is 1.0.

beta_float, optional

The \(\beta\) parameter. Default is 1.0.

locfloat, optional

The location parameter, for shifting. Default is 0.0.

scalefloat, optional

The scale parameter, for scaling. Default is 1.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as x, containing the evaluated values.

Notes

The Beta PDF is defined as:

\[f(y; \alpha, \beta) = \frac{y^{\alpha - 1} (1 - y)^{\beta - 1}}{B(\alpha, \beta)}\]

where \(B(\alpha, \beta)\) is the Beta function (see, ssp.beta), and \(y\) is the transformed value of \(x\) such that:

\[y = \frac{x - \text{loc}}{\text{scale}}\]

The final PDF is expressed as \(f(y)/\text{scale}\).

beta_log_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, alpha: float = 1.0, beta_: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute logPDF for BetaDistribution.

Parameters:
beta_float, optional

The \(\beta\) parameter. Default is 1.0.

xnp.ndarray

Input array of values where PDF is evaluated.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

alphafloat, optional

The \(\alpha\) parameter. Default is 1.0.

locfloat, optional

The location parameter, for shifting. Default is 0.0.

scalefloat, optional

The scale parameter, for scaling. Default is 1.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as x, containing the evaluated values.

Notes

The Beta logPDFis defined as

\[\ell(y) = (\alpha - 1)\ln(y) + (\beta - 1)\ln(1 - y) - \ln(\text{Beta}(\alpha, \beta))\]

where \(B(\alpha, \beta)\) is the beta function, and \(y\) is the transformed value of \(x\) such that:

\[y = \frac{x - \text{loc}}{\text{scale}}\]

The final logPDF is expressed as \(\ell(y) - \ln(\text{scale})\).

beta_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, alpha: float = 1.0, beta_: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute CDF for BetaDistribution.

Parameters:
beta_float, optional

The \(\beta\) parameter. Default is 1.0.

xnp.ndarray

Input array of values.

amplitudefloat, optional

For API consistency only.

alphafloat, optional

The \(\alpha\) parameter. Default is 1.0.

locfloat, optional

The location parameter, for shifting. Default is 0.0.

scalefloat, optional

The scale parameter, for scaling. Default is 1.0.

normalizebool, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as x, containing the evaluated values.

Notes

The Beta CDF is defined as:

\[F(y) = I_y(\alpha, \beta)\]

where \(I_y(\alpha, \beta)\) is the betainc function, and \(y\) is the transformed value of \(x\), defined as:

\[y = \frac{x - \text{loc}}{\text{scale}}\]

The final CDF is expressed as \(F(y)\).

beta_log_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, alpha: float = 1.0, beta_: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute logCDF for BetaDistribution.

Parameters:
beta_float, optional

The \(\beta\) parameter. Default is 1.0.

xnp.ndarray

Input array of values.

amplitudefloat, optional

For API consistency only.

alphafloat, optional

The \(\alpha\) parameter. Default is 1.0.

locfloat, optional

The location parameter, for shifting. Default is 0.0.

scalefloat, optional

The scale parameter, for scaling. Default is 1.0.

normalizebool, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as x, containing the evaluated values.

Notes

The Beta logCDF is defined as:

\[\mathcal{L}(y) = \ln I_y(\alpha, \beta)\]

where \(I_y(\alpha, \beta)\) is the betainc function, and \(y\) is the transformed value of \(x\), defined as:

\[y = \frac{x - \text{loc}}{\text{scale}}\]

The final logCDF is expressed as \(\mathcal{L}(y)\).

chi_square_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, degree_of_freedom: int | float = 1, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute PDF for ChiSquareDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

degree_of_freedomint, optional

The degrees of freedom parameter. Defaults to 1.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

scale: float, optional

The scale parameter, for scaling. Defaults to 1.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The ChiSquare PDF is defined as:

\[f(y\ |\ k) = \dfrac{y^{(k/2) - 1} e^{-y/2}}{2^{k/2} \Gamma(k/2)}\]

where \(\Gamma(\cdot)\) is the gamma function, and \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{x - \text{loc}}{\text{scale}}\]

The final PDF is expressed as \(f(y)/\text{scale}\).

chi_square_log_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, degree_of_freedom: int | float = 1, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log PDF for ChiSquareDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

degree_of_freedomint, optional

The degrees of freedom parameter. Defaults to 1.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

scale: float, optional

The scale parameter, for scaling. Defaults to 1.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The ChiSquare log PDF is defined as:

\[\ell(y\ |\ k) = \left(\dfrac{k}{2} - 1\right)\ln(y) - \dfrac{y}{2} - \dfrac{k}{2}\ln(2) - \ln\Gamma\left(\dfrac{k}{2}\right)\]

where \(\ln\Gamma(\cdot)\) is the gammaln function, and \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{x - \text{loc}}{\text{scale}}\]

The final PDF is expressed as \(\ell(y) - \ln(\text{scale})\).

chi_square_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, degree_of_freedom: int | float = 1, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute CDF for ChiSquareDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitude: float, optional

For API consistency only.

degree_of_freedomint, optional

The degrees of freedom parameter. Defaults to 1.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

scale: float, optional

The scale parameter, for scaling. Defaults to 1.0.

normalize: bool, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The ChiSquare CDF is defined as:

\[F(y) = \gamma\left(\dfrac{\nu}{2}, \dfrac{y}{2}\right)\]

where, \(\gamma\left(\cdot, \cdot\right)\) is the gammainc lower regularized incomplete gamma function, \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{x - \text{loc}}{\text{scale}}\]

The final CDF is expressed as \(F(y)\).

chi_square_log_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, degree_of_freedom: int | float = 1, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log CDF for ChiSquareDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitude: float, optional

For API consistency only.

degree_of_freedomint, optional

The degrees of freedom parameter. Defaults to 1.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

scale: float, optional

The scale parameter, for scaling. Defaults to 1.0.

normalize: bool, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The ChiSquare logCDF is defined as:

\[\mathcal{L}(y) = \ln\gamma\left(\dfrac{\nu}{2}, \dfrac{y}{2}\right)\]

where, \(\gamma\left(\cdot, \cdot\right)\) is the gammainc lower regularized incomplete gamma function, \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{x - \text{loc}}{\text{scale}}\]

The final log CDF is expressed as \(\mathcal{L}(y)\).

cubic(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], a: float = 1.0, b: float = 1.0, c: float = 1.0, d: float = 1.0) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Computes the y-values of a cubic function given x-values.

Parameters:
xnp.ndarray

Input array of values.

afloat

The coefficient of the cubic term (x^3).

bfloat

The coefficient of the quadratic term (x^2).

cfloat

The coefficient of the linear term (x).

dfloat

The constant term (y-intercept).

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The cubic function is defined as:

\[y = ax^3 + bx^2 + cx + d\]

where, \(a\), math:b, \(c\), and \(d\) are the cubic coefficients.

exponential_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, lambda_: float = 1.0, loc: float = 0.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute PDF for ExponentialDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

lambda_float, optional

The scale parameter, \(\lambda\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The Exponential PDF is defined as:

\[\begin{split}f(y, \lambda) = \begin{cases} \exp(-y) &;& y \geq 0, \\ 0 &;& y < 0. \end{cases}\end{split}\]

where, \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{x - \text{loc}}{\theta}\]

and \(\theta = \dfrac{1}{\lambda}\). The final PDF is expressed as \(f(y)/\theta\).

exponential_log_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, lambda_: float = 1.0, loc: float = 0.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log PDF for ExponentialDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

For API consistency only.

lambda_float, optional

The scale parameter, \(\lambda\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalizebool, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The Exponential log PDF is defined as:

\[\begin{split}\ell(y, \lambda) = \begin{cases} - y &;& y \geq 0, \\ -\infty &;& y < 0. \end{cases}\end{split}\]

where, \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{x - \text{loc}}{\theta}\]

and \(\theta = \dfrac{1}{\lambda}\). The final log PDF is expressed as \(\ell(y) - \ln(\theta)\).

exponential_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, lambda_: float = 1.0, loc: float = 0.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute CDF of ExponentialDistribution.

Note

This function uses ssp.gammainc to calculate the CDF with \(a = 1\) and \(x = \dfrac{x - \text{loc}}{\theta}\), where \(\theta = \dfrac{1}{\lambda}\).

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

For API consistency only.

lambda_float, optional

The scale parameter, \(\lambda\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalizebool, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The Exponential CDF is defined as:

\[F(y) = 1 - \exp\left[-y\right].\]

where, \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{x - \text{loc}}{\theta}\]

and \(\theta = \dfrac{1}{\lambda}\). The final CDF is expressed as \(F(y)\).

exponential_log_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, lambda_: float = 1.0, loc: float = 0.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log CDF of ExponentialDistribution.

Note

This function uses log transformation of ssp.gammainc to calculate the log CDF with \(a = 1\) and \(x = \dfrac{x - \text{loc}}{\theta}\), where \(\theta = \dfrac{1}{\lambda}\).

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

For API consistency only.

lambda_float, optional

The scale parameter, \(\lambda\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalizebool, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The Exponential log CDF is defined as:

\[\mathcal{L}(y) = \ln\left(1 -\exp(y)\right).\]

where \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{x - \text{loc}}{\theta}.\]

and \(\theta = \dfrac{1}{\lambda}\). The final log CDF is expressed as \(\mathcal{L}(y)\).

folded_normal_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, mean: float = 0.0, sigma: float = 1.0, loc: float = 0.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute PDF for FoldedNormalDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

meanfloat, optional

The mean parameter, \(\mu\). Defaults to 0.0.

sigmafloat, optional

The standard deviation parameter, \(\sigma\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The FoldedNormal PDF is defined as:

\[f(y\ |\ \mu, \sigma) = \phi(y\ |\ \mu, 1) + \phi(y\ |\ -\mu, 1),\]

where \(\phi\) is the PDF of GaussianDistribution, and \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{x - \text{loc}}{\text{scale}}\]

The final PDF is expressed as \(f(y)/\text{scale}\).

folded_normal_log_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, mean: float = 0.0, sigma: float = 1.0, loc: float = 0.0, normalize: bool = False)[source]#

Compute log PDF for FoldedNormalDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

meanfloat, optional

The mean parameter, \(\mu\). Defaults to 0.0.

sigmafloat, optional

The standard deviation parameter, \(\sigma\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The FoldedNormal PDF is defined as:

\[\ell(y\ |\ \mu, \sigma) = \ln\left(\phi(y\ |\ \mu, 1) + \phi(y\ |\ -\mu, 1)\right),\]

where \(\phi\) is the PDF of GaussianDistribution, and \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{x - \text{loc}}{\sigma}\]

The final log PDF is expressed as \(\ell(y) - \ln(\text{scale})\).

folded_normal_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, mean: float = 0.0, sigma: float = 1.0, loc: float = 0.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute CDF for FoldedNormalDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

For API consistency only.

meanfloat, optional

The mean parameter, \(\mu\). Defaults to 0.0.

sigmafloat, optional

The standard deviation parameter, \(\sigma\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalizebool, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The FoldedNormal CDF is defined as:

\[F(y) = \Phi(y\ | \mu, 1) + \Phi(y\ | -\mu, 1) - 1\]

where \(\Phi\) is the CDF of GaussianDistribution, and \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{x - \text{loc}}{\sigma}.\]

The final CDF is expressed as \(F(y)\).

folded_normal_log_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, mean: float = 0.0, sigma: float = 1.0, loc: float = 0.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log CDF for FoldedNormalDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

For API consistency only.

meanfloat, optional

The mean parameter, \(\mu\). Defaults to 0.0.

sigmafloat, optional

The standard deviation parameter, \(\sigma\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalizebool, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The FoldedNormal log CDF is defined as:

\[\mathcal{L}(y) = -\ln(2) + \ln\left[\text{erf}\left(\dfrac{q}{\sqrt{2}}\right) + \text{erf}\left(\dfrac{r}{\sqrt{2}}\right)\right]\]

where \(q = y + \mu\), \(r = y - \mu\), \(\text{erf}\) is erf function and \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{x - \text{loc}}{\sigma}.\]

The final logCDF is expressed as \(\mathcal{L}(y)\).

gamma_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, alpha: float = 1.0, theta: float = 1.0, loc: float = 0.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute PDF for GammaDistribution

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

alphafloat, optional

The shape parameter, \(\alpha\). Defaults to 1.0.

thetafloat, optional

The scale parameter, \(\theta\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

Important

The Gamma SS PDF is calculated via exponentiation of gamma_sr_log_pdf_() by setting \(\lambda = \dfrac{1}{\theta}\).

gamma_log_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, alpha: float = 1.0, theta: float = 1.0, loc: float = 0.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log PDF for GammaDistribution

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

alphafloat, optional

The shape parameter, \(\alpha\). Defaults to 1.0.

thetafloat, optional

The scale parameter, \(\theta\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

Important

The Gamma SS log PDF is calculated via gamma_sr_log_pdf_() by setting \(\lambda = \dfrac{1}{\theta}\).

gamma_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, alpha: float = 1.0, theta: float = 1.0, loc: float = 0.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute CDF for GammaDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitude: float, optional

For API consistency only.

alphafloat, optional

The shape parameter, \(\alpha\). Defaults to 1.0.

thetafloat, optional

The scale parameter, \(\theta\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalize: bool, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

Important

The Gamma SS CDF is calculated via gamma_sr_cdf_() by setting \(\lambda = \dfrac{1}{\theta}\).

gamma_log_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, alpha: float = 1.0, theta: float = 1.0, loc: float = 0.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log CDF for GammaDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitude: float, optional

For API consistency only.

alphafloat, optional

The shape parameter, \(\alpha\). Defaults to 1.0.

thetafloat, optional

The scale parameter, \(\theta\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalize: bool, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

Important

The Gamma SS log CDF is calculated via logarithm of gamma_sr_cdf_() by setting \(\lambda = \dfrac{1}{\theta}\).

gaussian_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude=1.0, mean=0.0, std=1.0, normalize=False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute PDF for GaussianDistribution

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

meanfloat, optional

The mean parameter, \(\mu\). Defaults to 0.0.

stdfloat, optional

The standard deviation parameter, \(\sigma\). Defaults to 1.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The Gaussian PDF is defined as:

\[f(x; \mu, \sigma) = \phi\left(\dfrac{x-\mu}{\sigma}\right) = \dfrac{1}{\sqrt{2\pi\sigma}}\exp\left[-\dfrac{1}{2}\left(\dfrac{x-\mu}{\sigma}\right)^2\right]\]

The final PDF is expressed as \(f(x)\).

gaussian_log_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, mean: float = 0.0, std: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log PDF for GaussianDistribution

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

meanfloat, optional

The mean parameter, \(\mu\). Defaults to 0.0.

stdfloat, optional

The standard deviation parameter, \(\sigma\). Defaults to 1.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The Gaussian log PDF is defined as:

\[\ell(x; \mu, \sigma) = -\dfrac{1}{2}\ln(2\pi) - \ln\sigma - \dfrac{1}{2}\left(\dfrac{x-\mu}{\sigma}\right)^2\]

The final log PDF is expressed as \(\ell(x)\).

gaussian_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, mean: float = 0.0, std: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute CDF for GaussianDistribution

Important

The calculation of gaussian CDF is done using ssp.ndtr function.

Parameters:
xnp.ndarray

Input array of values.

amplitude: float, optional

For API consistency only.

meanfloat, optional

The mean parameter, \(\mu\). Defaults to 0.0.

stdfloat, optional

The standard deviation parameter, \(\sigma\). Defaults to 1.0.

normalize: float, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The Gaussian CDF is defined as:

\[F(x) = \Phi\left(\dfrac{x-\mu}{\sigma}\right) = \dfrac{1}{2} \left[1 + \text{erf}\left(\dfrac{x - \mu}{\sigma\sqrt{2}}\right)\right]\]

The final CDF is expressed as \(F(x)\).

gaussian_log_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, mean: float = 0.0, std: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log CDF for GaussianDistribution

Important

The calculation of gaussian log CDF is done using ssp.log_ndtr function.

Parameters:
xnp.ndarray

Input array of values.

amplitude: float, optional

For API consistency only.

meanfloat, optional

The mean parameter, \(\mu\). Defaults to 0.0.

stdfloat, optional

The standard deviation parameter, \(\sigma\). Defaults to 1.0.

normalize: float, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The Gaussian log CDF is defined as:

\[\mathcal{L}(x) = \ln\Phi\left(\dfrac{x-\mu}{\sigma}\right)\]

The final log CDF is expressed as \(\mathcal{L}(x)\).

half_normal_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, sigma: float = 1.0, loc: float = 0.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute PDF for the HalfNormalDistribution.

Note

The HalfNormalDistribution is a special case of the FoldedNormalDistribution with \(\mu = 0\).

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

sigmafloat, optional

The standard deviation \(\sigma\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The HalfNormal PDF is defined as:

\[f(y\ |\ \sigma) = \sqrt{\dfrac{2}{\pi}}\exp\left(-\dfrac{y^2}{2}\right)\]

where \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{x - \text{loc}}{\text{scale}}.\]

The final PDF is expressed as \(f(y)/\text{scale}\).

half_normal_log_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, sigma: float = 1.0, loc: float = 0.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log PDF for the HalfNormalDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

sigmafloat, optional

The standard deviation \(\sigma\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The HalfNormal log PDF is defined as:

\[\ell(y\ |\ \sigma) = \dfrac{1}{2}\ln\left(\dfrac{2}{\pi}\right) - \dfrac{y^2}{2}\]

where \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{x - \text{loc}}{\text{scale}}.\]

The final log PDF is expressed as \(\ell(y) - \ln\left(\text{scale}\right)\).

half_normal_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, sigma: float = 1.0, loc: float = 0.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute the CDF for HalfNormalDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitude: float, optional

For API consistency only.

sigmafloat, optional

The standard deviation \(\sigma\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalize: float, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The HalfNormal CDF is defined as:

\[F(y) = \text{erf}\left(\frac{y}{\sqrt{2}}\right)\]

where \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{x - \text{loc}}{\text{scale}}.\]

The final CDF is expressed as \(F(y)\).

half_normal_log_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, sigma: float = 1.0, loc: float = 0.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute the log CDF for HalfNormalDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitude: float, optional

For API consistency only.

sigmafloat, optional

The standard deviation \(\sigma\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalize: float, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The HalfNormal log CDF is defined as:

\[\mathcal{L}(y) = \ln\text{erf}\left(\frac{y}{\sqrt{2}}\right)\]

where \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{x - \text{loc}}{\text{scale}}.\]

The final log CDF is expressed as \(\mathcal{L}(y)\).

laplace_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, mean: float = 0.0, diversity: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute PDF for the LaplaceDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

meanfloat, optional

The mean of laplace distribution. Defaults to 0.0.

diversityfloat, optional

The diversity parameter for laplace distribution. Defaults to 1.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The Laplace PDF is defined as:

\[f(y\ |\ \mu, b) = \dfrac{1}{2b}\exp\left(-\dfrac{|y|}{b}\right)\]

where \(y\) is the transformed value of \(x\), defined as:

\[y = x - \mu.\]

The final PDF is expressed as \(f(y)\).

laplace_log_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, mean: float = 0.0, diversity: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log PDF for the LaplaceDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

meanfloat, optional

The mean of laplace distribution. Defaults to 0.0.

diversityfloat, optional

The diversity parameter for laplace distribution. Defaults to 1.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The Laplace log PDF is defined as:

\[\ell(y\ |\ \mu, b) = -\ln(2b) - \dfrac{|y|}{b}\]

where \(y\) is the transformed value of \(x\), defined as:

\[y = x - \mu\]

The final log PDF is expressed as \(\ell(y)\).

laplace_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, mean: float = 0.0, diversity: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute CDF for LaplaceDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitude: float, optional

For API consistency only.

meanfloat, optional

The mean of laplace distribution. Defaults to 0.0.

diversityfloat, optional

The diversity parameter for laplace distribution. Defaults to 1.0.

normalize: bool, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The Laplace CDF is defined as:

\[\begin{split}F(x) = \begin{cases} \dfrac{1}{2}\exp\left(\dfrac{x-\mu}{b}\right) &,&x\leq\mu\\ 1 - \dfrac{1}{2}\exp\left(-\dfrac{x-\mu}{b}\right) &,&x\geq\mu \end{cases}\end{split}\]

The final CDF is expressed as \(F(x)\).

laplace_log_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, mean: float = 0.0, diversity: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log CDF for LaplaceDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitude: float, optional

For API consistency only.

meanfloat, optional

The mean of laplace distribution. Defaults to 0.0.

diversityfloat, optional

The diversity parameter for laplace distribution. Defaults to 1.0.

normalize: bool, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The Laplace log CDF is defined as:

\[\begin{split}\mathcal{L}(x) = \begin{cases} -\ln(2) + \dfrac{x-\mu}{b} &,&x\leq\mu\\ \ln\left[1 - \dfrac{1}{2}\exp\left(-\dfrac{x-\mu}{b}\right)\right] &,&x\geq\mu \end{cases}\end{split}\]
line(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], slope: float = 1.0, intercept: float = 0.0) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Computes the y-values of a line given x-values, slope, and intercept.

Parameters:
xnp.ndarray

Input array of values.

slopefloat

The slope of the line.

interceptfloat

The y-intercept of the line.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The line/linear function is defined as:

\[y = mx + c\]

where \(m\) is the slope and \(c\) is the intercept of the function.

log_normal_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, mean: float = 1.0, std: float = 1.0, loc: float = 0.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute PDF for LogNormalDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

meanfloat, optional

The mean parameter, \(\mu\). Defaults to 0.0.

stdfloat, optional

The standard deviation parameter, \(\sigma\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The LogNormal PDF is defined as:

\[f(y\ |\ \mu, \sigma) = \dfrac{1}{\sigma y\sqrt{2\pi}}\exp\left(-\dfrac{(\ln y - \mu)^2}{2\sigma^2}\right)\]

where, \(y\) is the transformed value of \(x\), defined as:

\[y = x - \text{loc}\]

The final PDF is expressed as \(f(y)\).

log_normal_log_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, mean: float = 1.0, std: float = 1.0, loc: float = 0.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log PDF for LogNormalDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

meanfloat, optional

The mean parameter, \(\mu\). Defaults to 0.0.

stdfloat, optional

The standard deviation parameter, \(\sigma\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The LogNormal log PDF is defined as:

\[f(y\ |\ \mu, \sigma) = -\ln(\sigma) -\ln(y) - 0.5\ln(2\pi) -\dfrac{1}{2}\dfrac{(\ln y - \mu)^2}{\sigma^2}\]

where, \(y\) is the transformed value of \(x\), defined as:

\[y = x - \text{loc}\]

The final PDF is expressed as \(f(y)\).

log_normal_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, mean: float = 1.0, std=1.0, loc: float = 0.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute CDF of LogNormalDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitude: float, optional

For API consistency only.

meanfloat, optional

The mean parameter, \(\mu\). Defaults to 0.0.

stdfloat, optional

The standard deviation parameter, \(\sigma\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalize: bool, optional

For API consistency only

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

Important

The LogNormal CDF is defined as:

\[F(x) = \Phi\left(\dfrac{\ln x - \mu}{\sigma}\right)\]

which can be calculated via ssp.ndtr function with ndtr(y), where \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{\ln(x - \text{loc}) - \mu}{\sigma}.\]
log_normal_log_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, mean: float = 1.0, std: float = 1.0, loc: float = 0.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log CDF of LogNormalDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitude: float, optional

For API consistency only.

meanfloat, optional

The mean parameter, \(\mu\). Defaults to 0.0.

stdfloat, optional

The standard deviation parameter, \(\sigma\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalize: bool, optional

For API consistency only

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

Important

The LogNormal log CDF is defined as:

\[F(x) = \ln\left[\Phi\left(\dfrac{\ln x - \mu}{\sigma}\right)\right]\]

which can be calculated via ssp.log_ndtr function function with log_ndtr(y), where \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{\ln(x - \text{loc}) - \mu}{\sigma}.\]
quadratic(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], a: float = 1.0, b: float = 1.0, c: float = 1.0) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Computes the y-values of a quadratic function given x-values.

Parameters:
xnp.ndarray

Input array of values.

afloat

The coefficient of the quadratic term (x^2).

bfloat

The coefficient of the linear term (x).

cfloat

The constant term (y-intercept).

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The quadratic function is defined as:

\[y = ax^2 + bx + c\]

where, \(a\), \(b\), and \(c\) are the quadratic coefficients.

scaled_inv_chi_square_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, df: float = 1.0, scale: float = 1.0, loc: float = 0.0, normalize: bool = False)[source]#

Compute PDF of ScaledInverseChiSquareDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

dffloat, optional

The degree of freedom. Defaults to 1.0.

scale: float, optional

The scale parameter, for scaling. Defaults to 1.0,

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The Scaled Inverse ChiSquare PDF is defined as:

\[f(y\ | \nu,\phi) = \dfrac{\tau^2\nu_2}{\Gamma(\nu_2)}\dfrac{1}{y^{1+\nu_2}}\exp\left[-\dfrac{\nu\tau^2}{2y}\right]\]

where \(\nu_2 = \dfrac{\nu}{2}\), \(\tau^2 = \dfrac{\phi}{\nu}\) and \(y\) is the transformed value of \(x\), defined as:

\[y = x - \text{loc}\]

The final PDF is expressed as \(f(y)\).

scaled_inv_chi_square_log_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, df: int | float = 1.0, scale: float = 1.0, loc: float = 0.0, normalize: bool = False)[source]#

Compute logPDF of ScaledInverseChiSquareDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

dffloat, optional

The degree of freedom. Defaults to 1.0.

scale: float, optional

The scale parameter, for scaling. Defaults to 1.0,

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The Scaled Inverse ChiSquare PDF is defined as:

\[\ell(y) = \ln(\tau^2\nu_2) - \ln\Gamma(\nu_2) - (1+\nu_2)\ln(\nu) - \dfrac{\nu\tau^2}{2y}\]

where \(\ln\) is the natural logarithm, \(\ln\Gamma(\cdot)\) is the gammaln function, \(\nu_2 = \dfrac{\nu}{2}\), \(\tau^2 = \dfrac{\phi}{\nu}\) and \(y\) is the transformed value of \(x\), defined as:

\[y = x - \text{loc}\]

The final PDF is expressed as \(\ell(y)\).

scaled_inv_chi_square_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, df: int | float = 1.0, scale: float = 1.0, loc: float = 0.0, normalize: bool = False)[source]#

Compute CDF of ScaledInverseChiSquareDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

For API consistency only.

dffloat, optional

The degree of freedom. Defaults to 1.0.

scale: float, optional

The scale parameter, for scaling. Defaults to 1.0,

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalizebool, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The Scaled Inverse ChiSquare CDF is defined as:

\[F(y) = \Gamma\left(\nu_2, \dfrac{\tau^2\nu_2}{y}\right)\]

where \(\nu_2 = \dfrac{\nu}{2}\), \(\tau^2 = \dfrac{\phi}{\nu}\), \(\Gamma(a, b)\) is the regularized upper gamma function, see ssp.gammaincc,and \(y\) is the transformed value of \(x\), defined as:

\[y = x - \text{loc}\]

The final CDF is expressed as \(F(y)\).

scaled_inv_chi_square_log_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, df: int | float = 1.0, scale: float = 1.0, loc: float = 0.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log CDF of ScaledInverseChiSquareDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

dffloat, optional

The degree of freedom. Defaults to 1.0.

scale: float, optional

The scale parameter, for scaling. Defaults to 1.0,

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The Scaled Inverse ChiSquare log CDF is defined as:

\[\mathcal{L}(y) = \ln\left[\Gamma\left(\nu_2, \dfrac{\tau^2\nu_2}{y}\right)\right]\]

where \(\nu_2 = \dfrac{\nu}{2}\), \(\tau^2 = \dfrac{\phi}{\nu}\), \(\Gamma(a, b)\) is the regularized upper gamma function, see ssp.gammaincc,and \(y\) is the transformed value of \(x\), defined as:

\[y = x - \text{loc}\]

The final log CDF is expressed as \(\mathcal{L}(y)\).

skew_normal_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, shape: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute PDF of SkewNormalDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

shapefloat, optional

The shape parameter, \(\alpha\). Defaults to 0.0.

locfloat, optional

The location parameter, \(\xi\). Defaults to 0.0.

scale: float, optional

The scale parameter, \(\omega\) Defaults to 1.0,

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The SkewNormal PDF is defined as:

\[f(y\ |\ \alpha, \xi, \omega) = 2\phi(y)\Phi(\alpha y)\]

where, \(\phi(y)\) and \(\Phi(\alpha y)\) are the GaussianDistribution PDF and CDF defined at \(y\) and \(\alpha y\) respectively. Additionally, \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{x - \xi}{\omega}\]

The final PDF is expressed as \(f(y)/\omega\).

skew_normal_log_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, shape: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log PDF of SkewNormalDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

shapefloat, optional

The shape parameter, \(\alpha\). Defaults to 0.0.

locfloat, optional

The location parameter, \(\xi\). Defaults to 0.0.

scale: float, optional

The scale parameter, \(\omega\) Defaults to 1.0,

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The SkewNormal log PDF is defined as:

\[\ell(y\ |\ \alpha, \xi, \omega) = \ln(2) + \ln\phi(y) + \ln\Phi(\alpha y)\]

where, \(\phi(y)\) and \(\Phi(\alpha y)\) are the GaussianDistribution PDF and CDF defined at \(y\) and \(\alpha y\) respectively. Additionally, \(y\) is the transformed value of \(x\), defined as:

\[y = \dfrac{x - \xi}{\omega}\]

The final log PDF is expressed as \(\ell(y)/\omega\).

skew_normal_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, shape: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False)[source]#

Compute CDF of SkewNormalDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitude: float, optional

For API consistency only.

shapefloat, optional

The shape parameter, \(\alpha\). Defaults to 0.0.

locfloat, optional

The location parameter, \(\xi\). Defaults to 0.0.

scale: float, optional

The scale parameter, \(\omega\) Defaults to 1.0,

normalize: float, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The SkewNormal CDF is defined as:

\[F(y) = \Phi(y) - 2T(y, \alpha)\]

where, \(T\) is the Owen’s T function, see ssp.owens_t, and \(\Phi(\cdot)\) is the GaussianDistribution CDF function, and \(y\) is the transformed value of \(x\), defined as:

\[y = \frac{x - \text{loc}}{\text{scale}}\]

The final CDF is expressed as \(F(y)\).

sym_gen_normal_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, shape: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute PDF of SymmetricGeneralizedNormalDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

shapefloat, optional

The shape parameter, \(\beta\). Defaults to 1.0.

locfloat, optional

The location parameter, \(\mu\). Defaults to 0.0.

scale: float, optional

The scale parameter, \(\alpha\) Defaults to 1.0,

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The SymmetricGeneralizedNormalDistribution PDF is defined as:

\[f(y\ |\ \beta, \mu, \alpha) = \dfrac{\beta}{2\Gamma(1/\beta)}\exp\left(-|y|^\beta\right)\]

where, \(\Gamma\) is the ssp.gamma function, and \(y\) is the transformed value of \(x\), defined as:

\[y = \frac{x - \mu}{\alpha}\]

The final PDF is expressed as \(f(y)/\alpha\).

sym_gen_normal_log_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, shape: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log PDF of SymmetricGeneralizedNormalDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

shapefloat, optional

The shape parameter, \(\beta\). Defaults to 1.0.

locfloat, optional

The location parameter, \(\mu\). Defaults to 0.0.

scale: float, optional

The scale parameter, \(\alpha\) Defaults to 1.0,

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The SymmetricGeneralizedNormalDistribution log PDF is defined as:

\[\ell(y\ |\ \beta, \mu, \alpha) = \ln(\beta) - \ln(2) - \ln\Gamma\left(\dfrac{1}{\beta}\right) - |y|^\beta\]

where, \(\Gamma\) is the ssp.gamma function, and \(y\) is the transformed value of \(x\), defined as:

\[y = \frac{x - \mu}{\alpha}\]

The final log PDF is expressed as \(\ell(y)/\alpha\).

sym_gen_normal_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, shape: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute CDF of SymmetricGeneralizedNormalDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitude: float, optional

For API consistency only.

shapefloat, optional

The shape parameter, \(\beta\). Defaults to 1.0.

locfloat, optional

The location parameter, \(\mu\). Defaults to 0.0.

scale: float, optional

The scale parameter, \(\alpha\) Defaults to 1.0,

normalize: bool, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The SymmetricGeneralizedNormalDistribution CDF is defined as:

\[F(y) = \dfrac{1}{2} + \dfrac{\text{sign}(y)}{2}\gamma\left(\dfrac{1}{\beta},|y|^\beta\,\right)\]

where \(\gamma(\cdot,\cdot)\) is the regularized lower incomplete gamma function, see gammainc, and \(y\) is the transformed value of \(x\), defined as:

\[y = \frac{x - \text{loc}}{\text{scale}}\]

The final CDF is expressed as \(F(y)\).

sym_gen_normal_log_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, shape: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log CDF of SymmetricGeneralizedNormalDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitude: float, optional

For API consistency only.

shapefloat, optional

The shape parameter, \(\beta\). Defaults to 1.0.

locfloat, optional

The location parameter, \(\mu\). Defaults to 0.0.

scale: float, optional

The scale parameter, \(\alpha\) Defaults to 1.0,

normalize: bool, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The SymmetricGeneralizedNormalDistribution log CDF is defined as:

\[\mathcal{L}(y) = \ln\left[\dfrac{1}{2} + \dfrac{\text{sign}(y)}{2}\gamma\left(\dfrac{1}{\beta},|y|^\beta\,\right)\right]\]

where \(\gamma(\cdot,\cdot)\) is the lower incomplete gamma function, see gammainc, and \(y\) is the transformed value of \(x\), defined as:

\[y = \frac{x - \text{loc}}{\text{scale}}\]

The final PDF is expressed as \(f(y)/\text{scale}\).

uniform_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, low: float = 0.0, high: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute PDF of UniformDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitudefloat, optional

The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

lowfloat, optional

The lower bound, \(a\). Defaults to 0.0.

highfloat, optional

The upper bound, \(b\). Defaults to 1.0.

normalizebool, optional

If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The Uniform PDF is defined as:

\[f(x\ |\ a, b) = \dfrac{1}{\beta - a}\]

Where \(\beta = a + b\) consistent with loc and scale factors and the final PDF is expressed as, \(f(x)\).

uniform_log_pdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, low: float = 0.0, high: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log PDF of UniformDistribution.

Notes

The Uniform log PDF is defined as:

\[\ell(x\ |\ a, b) = -\ln(\beta - a)\]

where \(\beta = a + b\) is consistent with loc and scale factors, and the final logPDF is expressed as, \(\ell(x)\).

uniform_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, low: float = 0.0, high: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute CDF of UniformDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitude: float, optional

For API consistency only.

lowfloat, optional

The lower bound, \(a\). Defaults to 0.0.

highfloat, optional

The upper bound, \(b\). Defaults to 1.0.

normalize: bool, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The Uniform CDF is defined as:

\[\begin{split}F(x) = \begin{cases} 0 &,& x < a\\ \dfrac{x-a}{b-a} &,& x \in [a, b]\\ 1 &,& x > b \end{cases}\end{split}\]
uniform_log_cdf_(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float = 1.0, low: float = 0.0, high: float = 1.0, normalize: bool = False) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Compute log CDF of UniformDistribution.

Parameters:
xnp.ndarray

Input array of values.

amplitude: float, optional

For API consistency only.

lowfloat, optional

The lower bound, \(a\). Defaults to 0.0.

highfloat, optional

The upper bound, \(b\). Defaults to 1.0.

normalize: bool, optional

For API consistency only.

Returns:
np.ndarray

Array of the same shape as \(x\), containing the evaluated values.

Notes

The Uniform log CDF is defined as:

\[\begin{split}\mathcal{L}(x) = \begin{cases} -\infty &,& x < a\\ \ln\left(\dfrac{x-a}{\beta-a}\right) &,& x \in [a, b]\\ 0 &,& x > \beta \end{cases}\end{split}\]

The final logCDF is expressed as, \(\mathcal{L}(x)\).

Internal functions#

_folded(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], mean: float, loc: float, scale: float, g_func: Callable)[source]#

Precompute the gaussian part of FoldedNormalDistribution.

Parameters:
xnp.ndarray

Input array of values.

meanfloat, optional

The mean parameter, \(\mu\). Defaults to 0.0.

scalefloat, optional

The standard deviation parameter, \(\sigma\). Defaults to 1.0.

locfloat, optional

The location parameter, for shifting. Defaults to 0.0.

g_funcCallable

The gaussian function, either PDF or CDF.

Returns:
np.ndarray

The additive gaussian part of the folded normal distribution.

_pdf_scaling(pdf_: Annotated[ndarray[Any, dtype[float64]], '1D array'], amplitude: float) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Scales a given PDF by a specified amplitude, normalizing it relative to its maximum value.

Parameters:
pdf_np.ndarray

The input probability density function values (not necessarily normalized).

amplitudefloat

The amplitude factor to scale the normalized PDF.

Returns:
NdArray

The scaled PDF array.

_gamma(x, a, un_log=False)[source]#
preprocess_input(x: Annotated[ndarray[Any, dtype[float64]], '1D array'], loc: float = 0.0, scale: float = 1.0) Annotated[ndarray[Any, dtype[float64]], '1D array'][source]#

Preprocess the input array, checking for scalar input, handling empty arrays, and loc-scale normalizaing the data.

Parameters:
xnp.ndarray

Input data.

locfloat, optional

The location parameter, for shifting, defaults to 0.0.

scale: float, optional

The scale parameter, for scaling, defaults to 1.0,

Returns:
np.ndarray

loc-scale shifted numpy array.