ExponentialDecay Class

class Stats_Analysis.Base_Dist.ExponentialDecay_Class.ExponentialDecay(lamb, lower_bound=None, upper_bound=None)[source]

Bases: object

Exponential decay probability distribution.

This class supports computation of the PDF and CDF for scalar and array inputs, with optional truncation. Uses scipy.stats.expon for the underlying exponential distribution.

Parameters:
  • lamb (float) – The decay constant of the exponential decay, lambda. Must be lamb > 0.

  • lower_bound (float, optional) – The lower bound. Default is None, meaning no lower bound is applied.

  • upper_bound (float, optional) – The upper bound. Default is None, meaning no upper bound is applied.

Raises:

ValueError – If lamb is not positive. If lower_bound >= upper_bound. If lower_bound or upper_bound < 0.

__init__(lamb, lower_bound=None, upper_bound=None)[source]

Initialize the exponential decay distribution with optional truncation.

_calc_trunc_fact()[source]

Calculate the normalisation factor if the distribution has been truncated. ie limits applied

cdf(X)[source]

Calculate the Cumulative Distribution Function (CDF).

Parameters:

X (float or np.ndarray) – The value(s) at which to evaluate the truncated CDF.

Returns:

The truncated CDF value(s).

Return type:

float or np.ndarray

Notes

  • For values less than lower_bound, the CDF equals 0.

  • For values greater than upper_bound, the CDF equals 1

  • Within the bounds, the CDF is scaled by the truncation factor.

cdf_fitting(X, lamb)[source]

Calculate the Cumulative Distribution Function (CDF) with no set parameters, automatically including truncation if bounds are set, for use in Binned MLE fitting.

Parameters:

X (float or np.ndarray) – The value(s) at which to evaluate the truncated CDF.

Returns:

The truncated CDF value(s).

Return type:

float or np.ndarray

Notes

  • For values less than lower_bound, the CDF equals 0.

  • For values greater than upper_bound, the CDF equals 1

  • Within the bounds, the CDF is scaled by the truncation factor.

normalisation_check()[source]

Perform a numerical integration using scipy.integrate.quad to check the normalization of the PDF.

If the PDF has been truncated: It is first performed over the region the PDF is defined [lower_bound, upper_bound]

It is then performed over the entire real line (-infinity to infinity).

Prints the results of the numerical integrations.

pdf(X)[source]

Calculate the Probability Density Function (PDF), automatically including truncation if bounds are set.

Parameters:

X (float or np.ndarray) – The value(s) at which to evaluate the PDF.

Returns:

The normalized PDF value(s), accounting for optional truncation.

Return type:

float or np.ndarray

Notes

  • For Z > -beta, the PDF is defined by lower_bound Gaussian core.

  • For Z <= -beta, the PDF transitions to a power-law tail.

  • If truncation bounds are provided, the PDF is zero outside the truncation range.

pdf_fitting(X, lamb)[source]

Calculate the Probability Density Function (PDF) for a given decay constant, for use with MLE fitting.

plot_dist()[source]

Plot the PDF and CDF for the Crystal Ball distribution.

If both lower and upper bounds are set: The PDF and CDF are plotted between[lower_bound, upper_bound].

If both lower and upper bounds are not set: The PDF and CDF is plotted between [mu - 5*sigma, mu + 5*sigma]