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: float | ndarray, amplitude: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute PDF of
ArcSineDistribution.- Parameters:
- xfArray
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: float | ndarray, amplitude: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False)[source]#
Compute logPDF of
ArcSineDistribution.- Parameters:
- xfArray
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: float | ndarray, amplitude: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute CDF of
ArcSineDistribution.- Parameters:
- xfArray
Input array of values where PDF is evaluated.
- amplitude: float, optional
For API consistency only.
- 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.
- normalize: bool, optional
For API consistency only.
- Returns:
- np.ndarray
Array of the same shape as \(x\), containing the evaluated values.
Notes
The ArcSine CDF is defined as:
\[F(y) = \left(\frac{2}{\pi}\right)\arcsin(\sqrt{y})\]where \(y\) is the transformed value of \(x\), defined as:
\[y = \dfrac{x - \text{loc}}{\text{scale}}.\]
- arc_sine_log_cdf_(x: float | ndarray, amplitude: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute log CDF of
ArcSineDistribution.- Parameters:
- xfArray
Input array of values where PDF is evaluated.
- amplitude: float, optional
For API consistency only.
- 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.
- normalize: bool, optional
For API consistency only.
- 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: float | ndarray, amplitude: float = 1.0, alpha: float = 1.0, beta: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute PDF of
BetaDistribution.- Parameters:
- xfArray
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.
- betafloat, 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 toFalse.
- 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,
scipy.special.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: float | ndarray, amplitude: float = 1.0, alpha: float = 1.0, beta: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute logPDF for
BetaDistribution.- Parameters:
- xfArray
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.
- betafloat, 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 toFalse.
- 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
betafunction, 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: float | ndarray, amplitude: float = 1.0, alpha: float = 1.0, beta: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute CDF for
BetaDistribution.- Parameters:
- xfArray
Input array of values.
- amplitudefloat, optional
For API consistency only.
- alphafloat, optional
The \(\alpha\) parameter. Default is 1.0.
- betafloat, 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
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
betaincfunction, 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: float | ndarray, amplitude: float = 1.0, alpha: float = 1.0, beta: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute logCDF for
BetaDistribution.- Parameters:
- xfArray
Input array of values.
- amplitudefloat, optional
For API consistency only.
- alphafloat, optional
The \(\alpha\) parameter. Default is 1.0.
- betafloat, 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
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
betaincfunction, 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: float | ndarray, amplitude: float = 1.0, degree_of_freedom: int | float = 1, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute PDF for
ChiSquareDistribution.- Parameters:
- xfArray
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 toFalse.
- 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
gammafunction, 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: float | ndarray, amplitude: float = 1.0, degree_of_freedom: int | float = 1, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute log PDF for
ChiSquareDistribution.- Parameters:
- xfArray
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 toFalse.
- 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
gammalnfunction, 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: float | ndarray, amplitude: float = 1.0, degree_of_freedom: int | float = 1, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute CDF for
ChiSquareDistribution.- Parameters:
- xfArray
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
gammainclower 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: float | ndarray, amplitude: float = 1.0, degree_of_freedom: int | float = 1, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute log CDF for
ChiSquareDistribution.- Parameters:
- xfArray
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
gammainclower 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)\).
- exponential_pdf_(x: float | ndarray, amplitude: float = 1.0, lambda_: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute PDF for
ExponentialDistribution.- Parameters:
- xfArray
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 toFalse.
- 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} \lambda \exp\left[-\lambda y\right] &;& y \geq 0, \\ 0 &;& y < 0. \end{cases}\end{split}\]where, \(y\) is the transformed value of \(x\), defined as:
\[y = x - \text{loc}\]The final PDF is expressed as \(f(y)\).
- exponential_log_pdf_(x: float | ndarray, amplitude: float = 1.0, lambda_: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute log PDF for
ExponentialDistribution.- Parameters:
- xfArray
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} \ln\lambda -\lambda y &;& y \geq 0, \\ -inf &;& y < 0. \end{cases}\end{split}\]where, \(y\) is the transformed value of \(x\), defined as:
\[y = x - \text{loc}\]The final log PDF is expressed as \(\ell(y)\).
- exponential_cdf_(x: float | ndarray, amplitude: float = 1.0, lambda_: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute CDF of
ExponentialDistribution.Note
This function uses
gamma_sr_cdf_()to calculate the CDF with \(\alpha = 1\) and \(\lambda_\text{gammaSR} = \lambda_\text{expon}\).- Parameters:
- xfArray
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(x) = 1 - \exp\left[-\lambda x\right].\]
- exponential_log_cdf_(x: float | ndarray, amplitude: float = 1.0, lambda_: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute log CDF of
ExponentialDistribution.- Parameters:
- xfArray
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(\lambda y)\right).\]where \(\ln(1-\theta)\) is calculated using
log1pfunction, and \(y\) is the transformed value of \(x\), defined as:\[y = x - \text{loc}.\]The final log CDF is expressed as \(\mathcal{L}(y)\).
- folded_normal_pdf_(x: float | ndarray, amplitude: float = 1.0, mean: float = 0.0, sigma: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute PDF for
FoldedNormalDistribution.- Parameters:
- xfArray
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 toFalse.
- 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: float | ndarray, 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:
- xfArray
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 toFalse.
- 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: float | ndarray, amplitude: float = 1.0, mean: float = 0.0, sigma: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute CDF for
FoldedNormalDistribution.- Parameters:
- xfArray
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: float | ndarray, amplitude: float = 1.0, mean: float = 0.0, sigma: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute log CDF for
FoldedNormalDistribution.- Parameters:
- xfArray
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
erffunction 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_sr_pdf_(x: float | ndarray, amplitude: float = 1.0, alpha: float = 1.0, lambda_: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute PDF for
GammaDistributionSR.- Parameters:
- xfArray
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.
- lambda_float, optional
The rate 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 toFalse.
- Returns:
- np.ndarray
Array of the same shape as \(x\), containing the evaluated values.
Notes
The Gamma SR PDF is defined as:
\[\begin{split}f(y; \alpha, \lambda) = \begin{cases} \dfrac{\lambda^\alpha}{\Gamma(\alpha)} y^{\alpha - 1} \exp\left[-\lambda y\right] &,& y > 0, \\ & \\ 0 &,& y < 0. \end{cases}\end{split}\]where \(y\) is the transformed value of \(x\), defined as:
\[y = x - \text{loc}\]The final PDF is expressed as \(f(y)\).
- gamma_sr_log_pdf_(x: float | ndarray, amplitude: float = 1.0, alpha: float = 1.0, lambda_: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute log PDF for
GammaDistributionSR.- Parameters:
- xfArray
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.
- lambda_float, optional
The rate 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 toFalse.
- Returns:
- np.ndarray
Array of the same shape as \(x\), containing the evaluated values.
Notes
The Gamma SR log PDF is defined as:
\[\begin{split}\ell(y; \alpha, \lambda) = \begin{cases} \alpha\ln\lambda + (\alpha - 1)\ln(y) - \lambda y - \ln\Gamma(\alpha) &,& y > 0, \\ & \\ -\infty &,& y < 0. \end{cases}\end{split}\]where \(y\) is the transformed value of \(x\), defined as:
\[y = x - \text{loc}\]The final PDF is expressed as \(\ell(y)\).
- gamma_sr_cdf_(x: float | ndarray, amplitude: float = 1.0, alpha: float = 1.0, lambda_: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute CDF for
GammaDistributionSR.- Parameters:
- xfArray
Input array of values.
- amplitude: float, optional
For API consistency only.
- alphafloat, optional
The shape parameter, \(\alpha\). Defaults to 1.0.
- lambda_float, optional
The rate parameter, \(\lambda\). 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 Gamma SR CDF is defined as:
\[F(y) = \dfrac{1}{\Gamma(\alpha)}\gamma(\alpha, \lambda y)\]where, \(\dfrac{\gamma(a, b)}{\Gamma(a)}\) is the regularized lower incomplete gamma function, see
gammainc, and \(y\) is the transformed value of \(x\), defined as:\[y = x - \text{loc}\]The final CDF is expressed as \(F(y)\).
- gamma_sr_log_cdf_(x: float | ndarray, amplitude: float = 1.0, alpha: float = 1.0, lambda_: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute log CDF for
GammaDistributionSR.- Parameters:
- xfArray
Input array of values.
- amplitude: float, optional
For API consistency only.
- alphafloat, optional
The shape parameter, \(\alpha\). Defaults to 1.0.
- lambda_float, optional
The rate parameter, \(\lambda\). 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 Gamma SR log CDF is defined as:
\[\mathcal{L}(y) = -\ln\Gamma(\alpha) + \ln\gamma(\alpha, \lambda y)\]where, \(-\ln\Gamma(a) + \ln\gamma(a, b)\) is the logarithm of regularized lower incomplete gamma function, see
gammainc, and \(y\) is the transformed value of \(x\), defined as:\[y = x - \text{loc}\]The final log CDF is expressed as \(\mathcal{L}(y)\).
- gamma_ss_pdf_(x: float | ndarray, amplitude: float = 1.0, alpha: float = 1.0, theta: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute PDF for
GammaDistributionSS- Parameters:
- xfArray
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 toFalse.
- 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_ss_log_pdf_(x: float | ndarray, amplitude: float = 1.0, alpha: float = 1.0, theta: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute log PDF for
GammaDistributionSS- Parameters:
- xfArray
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 toFalse.
- 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_ss_cdf_(x: float | ndarray, amplitude: float = 1.0, alpha: float = 1.0, theta: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute CDF for
GammaDistributionSS.- Parameters:
- xfArray
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_ss_log_cdf_(x: float | ndarray, amplitude: float = 1.0, alpha: float = 1.0, theta: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute log CDF for
GammaDistributionSS.- Parameters:
- xfArray
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: float | ndarray, amplitude: float = 1.0, mean: float = 0.0, std: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute PDF for
GaussianDistribution- Parameters:
- xfArray
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 toFalse.
- 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: float | ndarray, amplitude: float = 1.0, mean: float = 0.0, std: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute log PDF for
GaussianDistribution- Parameters:
- xfArray
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 toFalse.
- 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: float | ndarray, amplitude: float = 1.0, mean: float = 0.0, std: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute CDF for
GaussianDistributionImportant
The calculation of gaussian CDF is done using
scipy.special.ndtrfunction.- Parameters:
- xfArray
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: float | ndarray, amplitude: float = 1.0, mean: float = 0.0, std: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute log CDF for
GaussianDistributionImportant
The calculation of gaussian log CDF is done using
scipy.special.log_ndtrfunction.- Parameters:
- xfArray
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: float | ndarray, amplitude: float = 1.0, sigma: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute PDF for the
HalfNormalDistribution.Note
The
HalfNormalDistributionis a special case of theFoldedNormalDistributionwith \(\mu = 0\).- Parameters:
- xfArray
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 toFalse.
- 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: float | ndarray, amplitude: float = 1.0, sigma: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute log PDF for the
HalfNormalDistribution.- Parameters:
- xfArray
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 toFalse.
- 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: float | ndarray, amplitude: float = 1.0, sigma: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute the CDF for
HalfNormalDistribution.- Parameters:
- xfArray
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: float | ndarray, amplitude: float = 1.0, sigma: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute the log CDF for
HalfNormalDistribution.- Parameters:
- xfArray
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: float | ndarray, amplitude: float = 1.0, mean: float = 0.0, diversity: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute PDF for the
LaplaceDistribution.- Parameters:
- xfArray
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 toFalse.
- 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: float | ndarray, amplitude: float = 1.0, mean: float = 0.0, diversity: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute log PDF for the
LaplaceDistribution.- Parameters:
- xfArray
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 toFalse.
- 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 = \dfrac{x - \mu}{b}.\]The final log PDF is expressed as \(\ell(y)\).
- laplace_cdf_(x: float | ndarray, amplitude: float = 1.0, mean: float = 0.0, diversity: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute CDF for
LaplaceDistribution.- Parameters:
- xfArray
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: float | ndarray, amplitude: float = 1.0, mean: float = 0.0, diversity: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute log CDF for
LaplaceDistribution.- Parameters:
- xfArray
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}\]
- log_normal_pdf_(x: float | ndarray, amplitude: float = 1.0, mean: float = 0.0, std: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute PDF for
LogNormalDistribution.- Parameters:
- xfArray
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 toFalse.
- 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: float | ndarray, amplitude: float = 1.0, mean: float = 0.0, std: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute log PDF for
LogNormalDistribution.- Parameters:
- xfArray
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 toFalse.
- 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: float | ndarray, amplitude: float = 1.0, mean: float = 0.0, std=1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute CDF of
LogNormalDistribution.- Parameters:
- xfArray
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
scipy.special.ndtrfunction withndtr(y), where \(y\) is the transformed value of \(x\), defined as:\[y = \dfrac{\ln(x - \text{loc}) - \mu}{\sigma}.\]
- log_normal_log_cdf_(x: float | ndarray, amplitude: float = 1.0, mean: float = 0.0, std: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute log CDF of
LogNormalDistribution.- Parameters:
- xfArray
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
scipy.special.log_ndtrfunction function withlog_ndtr(y), where \(y\) is the transformed value of \(x\), defined as:\[y = \dfrac{\ln(x - \text{loc}) - \mu}{\sigma}.\]
- scaled_inv_chi_square_pdf_(x, 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:
- xfArray
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 toFalse.
- 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: float | ndarray, 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:
- xfArray
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 toFalse.
- 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
gammalnfunction, \(\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: float | ndarray, 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:
- xfArray
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
scipy.special.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: float | ndarray, amplitude: float = 1.0, df: int | float = 1.0, scale: float = 1.0, loc: float = 0.0, normalize: bool = False) float | ndarray[source]#
Compute log CDF of
ScaledInverseChiSquareDistribution.- Parameters:
- xfArray
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 toFalse.
- 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
scipy.special.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: float | ndarray, amplitude: float = 1.0, shape: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute PDF of
SkewNormalDistribution.- Parameters:
- xfArray
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 toFalse.
- 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
GaussianDistributionPDF 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: float | ndarray, amplitude: float = 1.0, shape: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute log PDF of
SkewNormalDistribution.- Parameters:
- xfArray
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 toFalse.
- 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
GaussianDistributionPDF 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: float | ndarray, 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:
- xfArray
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
scipy.special.owens_t, and \(\Phi(\cdot)\) is theGaussianDistributionCDF 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: float | ndarray, amplitude: float = 1.0, shape: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute PDF of
SymmetricGeneralizedNormalDistribution.- Parameters:
- xfArray
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 toFalse.
- 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
scipy.special.gammafunction, 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: float | ndarray, amplitude: float = 1.0, shape: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute log PDF of
SymmetricGeneralizedNormalDistribution.- Parameters:
- xfArray
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 toFalse.
- 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
scipy.special.gammafunction, 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: float | ndarray, amplitude: float = 1.0, shape: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute CDF of
SymmetricGeneralizedNormalDistribution.- Parameters:
- xfArray
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: float | ndarray, amplitude: float = 1.0, shape: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute log CDF of
SymmetricGeneralizedNormalDistribution.- Parameters:
- xfArray
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: float | ndarray, amplitude: float = 1.0, low: float = 0.0, high: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute PDF of
UniformDistribution.- Parameters:
- xfArray
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 toFalse.
- 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
locandscalefactors and the final PDF is expressed as, \(f(x)\).
- uniform_log_pdf_(x: float | ndarray, amplitude: float = 1.0, low: float = 0.0, high: float = 1.0, normalize: bool = False) float | ndarray[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
locandscalefactors, and the final logPDF is expressed as, \(\ell(x)\).
- uniform_cdf_(x: float | ndarray, amplitude: float = 1.0, low: float = 0.0, high: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute CDF of
UniformDistribution.- Parameters:
- xfArray
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: float | ndarray, amplitude: float = 1.0, low: float = 0.0, high: float = 1.0, normalize: bool = False) float | ndarray[source]#
Compute log CDF of
UniformDistribution.- Parameters:
- xfArray
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#
- _beta_masking(y: float | ndarray, alpha: float, beta: float) float | ndarray[source]#
Creates a mask for beta distributions to identify out-of-range or undefined values.
- Parameters:
- yfArray
Array of values to check, typically in the range [0, 1].
- alphafloat
Alpha parameter of the beta distribution. Determines the shape of the distribution.
- betafloat
Beta parameter of the beta distribution. Determines the shape of the distribution.
- Returns:
- np.ndarray
A boolean mask array where True indicates out-of-range or undefined values.
- _folded(x: float | ndarray, 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_: float | ndarray, amplitude: float) float | ndarray[source]#
Scales a probability density function (PDF) by a given amplitude.
- Parameters:
- pdf_fArray
The input PDF array to be scaled.
- amplitudefloat
The amplitude to scale the PDF.
- Returns:
- np.ndarray
The scaled PDF array.
- _remove_nans(x: float | ndarray, nan_value=None) float | ndarray[source]#
Replaces NaN, positive infinity, and negative infinity values in an array.
- Parameters:
- xfArray
Input array that may contain NaN, positive infinity, or negative infinity values.
- Returns:
- np.ndarray
Array with NaN replaced by 0, positive infinity replaced by np.inf, and negative
- infinity replaced by -np.inf.
- preprocess_input(x, loc=0.0, scale=1.0)[source]#
Preprocess the input array by converting to float, checking for scalar input, handling empty arrays, and normalizing 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:
- tuple:
(processed array, scalar_input_flag)