Signal Class
- class Stats_Analysis.Compound_Dist.Signal_Class.Signal(mu, sigma, beta, m, lamb, lower_bound_X=None, upper_bound_X=None, lower_bound_Y=None, upper_bound_Y=None)[source]
Bases:
objectSignal probability distribution defined by S(X, Y) = CrystalBall(X) * ExponentialDecay(Y).
This class supports computation of the joint PDF and joint CDF for scalar and array inputs, with optional truncation for both X and Y.
- Parameters:
mu (float) – The mean of the CrystalBall distribution in the X dimension.
sigma (float) – The standard deviation of the CrystalBall distribution in the X dimension.
beta (float) – The threshold value of the CrystalBall distribution in the X dimension. Must be beta > 0.
m (float) – The power-law tail exponent of the CrystalBall distribution in the X dimension. Must be m > 1.
lamb (float) – The decay constant (rate) of the ExponentialDecay distribution in the Y dimension. Must be lamb > 0.
lower_bound_X (float, optional) – The lower bound for the CrystalBall distribution. Default is None.
upper_bound_X (float, optional) – The upper bound for the CrystalBall distribution. Default is None.
lower_bound_Y (float, optional) – The lower bound for the ExponentialDecay distribution. Default is None.
upper_bound_Y (float, optional) – The upper bound for the ExponentialDecay distribution. Default is None.
- Raises:
ValueError – If beta <= 0. If m <= 1. If lamb <= 0. If lower_bound_X >= upper_bound_X. If lower_bound_Y >= upper_bound_Y.
- __init__(mu, sigma, beta, m, lamb, lower_bound_X=None, upper_bound_X=None, lower_bound_Y=None, upper_bound_Y=None)[source]
Initialize the Signal distribution with optional truncation by defining the CrystalBall and ExponentialDecay distributions in the X and Y dimensions, respectively.
- cdf(X, Y)[source]
Compute the joint Cumulative Distribution Function (CDF).
The Joint CDF is defined as: C(X, Y) = Integral of S(X,Y) from 0, X and 0, Y
As the distributions are independent, the joint CDF is the product of the individual CDFs: C(X, Y) = CrystalBall_CDF(X) * Exponential_CDF(Y)
- Parameters:
X (float or np.ndarray) – The value(s) of X at which to evaluate the CDF.
Y (float or np.ndarray) – The value(s) of Y at which to evaluate the CDF.
- Returns:
The joint CDF value(s), 0 if X is outside [lower_bound_X, upper_bound_X] or Y is outside [lower_bound_Y, upper_bound_Y].
- Return type:
float or np.ndarray
- cdf_fitting(X, Y, mu, sigma, beta, m, lamb)[source]
Calculate the Cumulative Density Function (CDF) for a given set of parameters, for use with binned MLE fitting.
- normalisation_check(over_whole_plane=False)[source]
Check the normalization of the joint Probability Density Function (PDF) using numerical integration.
This method performs numerical integration with scipy.integrate.dblquad to ensure that the joint PDF integrates to 1. It supports both truncated and untruncated cases.
- Parameters:
over_whole_plane (bool, optional) – If True, perform integration over the entire real plane (-infinity to infinity) for both X and Y. Default is False, in which case integration is only performed over the defined/truncated region.
- Returns:
The defined/truncated region: [lower_bound_X, upper_bound_X] for X and [lower_bound_Y, upper_bound_Y] for Y.
The entire real plane: X in [-infinity, infinity] and Y in [-infinity, infinity] (only if over_whole_plane is True).
- Return type:
Normalisation results for
Notes
If the PDF is truncated, the method integrates over the truncated region defined by the bounds (lower_bound_X, upper_bound_X, lower_bound_Y, upper_bound_Y).
If no bounds are defined, the truncated region defaults to the entire real plane.
The integration over the entire real plane is computationally intensive and can be skipped by setting over_whole_plane to False.
- pdf(X, Y)[source]
Calculate the joint Probability Density Function (PDF).
The Joint PDF is defined as: S(X, Y) = CrystalBall_PDF(X) * Exponential_PDF(Y)
- Parameters:
X (float or np.ndarray) – The value(s) of X at which to evaluate the PDF.
Y (float or np.ndarray) – The value(s) of Y at which to evaluate the PDF.
- Returns:
The normalized joint PDF value(s) 0 if X is outside [lower_bound_X, upper_bound_X] or Y is outside [lower_bound_Y, upper_bound_Y].
- Return type:
float or np.ndarray