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: ndarray, amplitude: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) ndarray[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 PDF 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}\).
- beta_pdf_(x: ndarray, amplitude: float = 1.0, alpha: float = 1.0, beta: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) ndarray[source]#
Compute PDF of
BetaDistribution.- 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.- 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 PDF 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_cdf_(x: ndarray, amplitude: float = 1.0, alpha: float = 1.0, beta: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) ndarray[source]#
Compute CDF for
BetaDistribution.- Parameters:
- xnp.ndarray
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 PDF values.
Notes
The Beta CDF is defined as:
\[I_x(\alpha, \beta)\]where \(I_x(\alpha, \beta)\) is the regularized incomplete Beta function, see
betainc.
- chi_square_pdf_(x: ndarray, amplitude: float = 1.0, degree_of_freedom: int | float = 1, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) ndarray[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 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(k)\) is the
gammafunction, and \(y\) is the transformed value of \(x\), defined as:\[y = x - \text{loc}\]The final PDF is expressed as \(f(y)\).
- exponential_pdf_(x: ndarray, amplitude: float = 1.0, lambda_: float = 1.0, loc: float = 0.0, normalize: bool = False) ndarray[source]#
Compute PDF for
ExponentialDistribution.Note
This function uses
gamma_sr_pdf_()to calculate the PDF with \(\alpha = 1\) and \(\lambda_\text{gammaSR} = \lambda_\text{expon}\).- 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 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_cdf_(x: ndarray, amplitude: float = 1.0, scale: float = 1.0, loc: float = 0.0, normalize: bool = False) 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:
- 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(x) = 1 - \exp\left[-\lambda x\right].\]
- folded_normal_pdf_(x: ndarray, amplitude: float = 1.0, mean: float = 0.0, sigma: float = 1.0, loc: float = 0.0, normalize: bool = False) ndarray[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 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}}{\sigma}\]The final PDF is expressed as \(f(y)/\sigma\).
- folded_normal_cdf_(x: ndarray, amplitude: float = 1.0, mean: float = 0.0, sigma: float = 1.0, loc: float = 0.0, normalize: bool = False) ndarray[source]#
Compute CDF for
FoldedNormalDistribution.- Parameters:
- xnp.ndarray
Input array of values.
- amplitude: float, 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.
- normalize: bool, 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}\]
- gamma_sr_pdf_(x: ndarray, amplitude: float = 1.0, alpha: float = 1.0, lambda_: float = 1.0, loc: float = 0.0, normalize: bool = False) ndarray[source]#
Compute PDF for
GammaDistributionSRwith \(\alpha\) (shape) and \(\lambda\) (rate) parameters.- 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.
- 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 PDF 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 > \text{loc}, \\ 0, & y \leq \text{loc}. \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_cdf_(x: ndarray, amplitude: float = 1.0, alpha: float = 1.0, lambda_: float = 1.0, loc: float = 0.0, normalize: bool = False) ndarray[source]#
Compute CDF for
GammaDistributionSRwith \(\alpha\) and \(\lambda\) parameters.- Parameters:
- xnp.ndarray
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 PDF values.
Notes
The Gamma CDF is defined as:
\[F(x) = \dfrac{1}{\Gamma(\alpha)}\gamma(\alpha, \lambda x)\]where, \(\gamma(\alpha, \lambda x)\) is the lower incomplete gamma function, see
gammainc.
- gamma_ss_pdf_(x: ndarray, amplitude: float = 1.0, alpha: float = 1.0, theta: float = 1.0, normalize: bool = False) ndarray[source]#
Compute PDF for
GammaDistributionSSwith \(\alpha\) (shape) and \(\theta\) (scale) parameters.- 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, \(\lambda\). 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 Gamma SS PDF is defined as:
\[f(y\ |\ \alpha, \theta) = \dfrac{1}{\Gamma(\alpha)\theta^\alpha}y^{\alpha-1}\exp\left[-\dfrac{y}{\theta}\right]\]where \(y\) is the transformed value of \(x\), defined as:
\[y = x - \text{loc}\]The final PDF is expressed as \(f(y)\).
- gaussian_pdf_(x: ndarray, amplitude: float = 1.0, mean: float = 0.0, std: float = 1.0, normalize: bool = False) ndarray[source]#
Compute PDF for the
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 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_cdf_(x: ndarray, amplitude: float = 1.0, mean: float = 0.0, std: float = 1.0, normalize: bool = False) ndarray[source]#
Compute CDF for the
GaussianDistribution- 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]\]
- half_normal_pdf_(x: ndarray, amplitude: float = 1.0, sigma: float = 1.0, loc: float = 0.0, normalize: bool = False) ndarray[source]#
Compute PDF for the
HalfNormalDistribution.Note
The
HalfNormalDistribution. is a special case of theFoldedNormalDistributionwith \(\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 toFalse.
- Returns:
- np.ndarray
Array of the same shape as \(x\), containing the evaluated values.
Notes
The HalfNormal PDF is defined as:
\[f(x\ |\ \sigma) = \sqrt{\dfrac{2}{\pi\sigma^2}}\exp\left[-\dfrac{x^2}{2\sigma^2}\right]\]where \(x >= 0\).
- half_normal_cdf_(x: ndarray, amplitude: float = 1.0, scale: float = 1.0, loc: float = 0.0, normalize: bool = False) ndarray[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(x) = \text{erf}\left( \frac{x}{\sqrt{2\sigma^2}}\right)\]
- laplace_pdf_(x: ndarray, amplitude: float = 1.0, mean: float = 0.0, diversity: float = 1.0, normalize: bool = False) ndarray[source]#
Compute PDF for
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 parameter, \(\mu\). Defaults to 0.0.
- diversityfloat, optional
The diversity parameter, \(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 Laplace PDF is defined as:
\[f(x\ |\ \mu, b) = \dfrac{1}{2b}\exp\left(-\dfrac{|x - \mu|}{b}\right)\]The final PDF is expressed as \(f(x)\).
- laplace_cdf_(x: ndarray, amplitude: float = 1.0, mean: float = 0.0, diversity: float = 1.0, normalize: bool = False) ndarray[source]#
Compute CDF for
LaplaceDistribution.- Parameters:
- xnp.ndarray
Input array of values.
- amplitude: float, optional
For API consistency only.
- meanfloat, optional
The mean parameter, \(\mu\). Defaults to 0.0.
- diversityfloat, optional
The diversity parameter, \(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 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}\]
- log_normal_pdf_(x: ndarray, amplitude: float = 1.0, mean: float = 0.0, std: float = 1.0, loc: float = 0.0, normalize: bool = False) ndarray[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 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_cdf_(x: ndarray, amplitude: float = 1.0, mean: float = 0.0, std=1.0, loc: float = 0.0, normalize: bool = False) ndarray[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
The LogNormal CDF is defined as:
\[F(x) = \Phi\left(\dfrac{\ln x - \mu}{\sigma}\right)\]
- skew_normal_pdf_(x: ndarray, amplitude: float = 1.0, shape: float = 0.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False) ndarray[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 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_cdf_(x: ndarray, amplitude: float = 1.0, shape: float = 0.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(x) = \Phi\left(\dfrac{x - \xi}{\omega}\right) - 2T\left(\dfrac{x - \xi}{\omega}, \alpha\right)\]where, \(T\) is the Owen’s T function, see
scipy.special.owens_t, and \(\Phi(\cdot)\) is theGaussianDistributionCDF function.
- uniform_pdf_(x: ndarray, amplitude: float = 1.0, low: float = 0.0, high: float = 1.0, normalize: bool = False) ndarray[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 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}{b-a}\]
- uniform_cdf_(x: ndarray, amplitude: float = 1.0, low: float = 0.0, high: float = 1.0, normalize: bool = False) ndarray[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}\]
Internal functions#
- _beta_masking(y: ndarray, alpha: float, beta: float) ndarray[source]#
Creates a mask for beta distributions to identify out-of-range or undefined values.
- Parameters:
- ynp.ndarray
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.
- _pdf_scaling(pdf_: ndarray, amplitude: float) ndarray[source]#
Scales a probability density function (PDF) by a given amplitude.
- Parameters:
- pdf_np.ndarray
The input PDF array to be scaled.
- amplitudefloat
The amplitude to scale the PDF.
- Returns:
- np.ndarray
The scaled PDF array.
- _remove_nans(x: ndarray) ndarray[source]#
Replaces NaN, positive infinity, and negative infinity values in an array.
- Parameters:
- xnp.ndarray
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.