mixle.stats.univariate.continuous.exgaussian module¶
Exponentially-modified Gaussian distributions over real values.
- Observations are real-valued floats. The EMG models
X = N(mu, sigma2) + Exp(rate=lam)– a Gaussian convolved with a positive-shifting exponential, giving a right-skewed density. Its stable log-density is
log f(x) = log(lam/2) - 0.5*u^2 + log(erfcx(z)),
where
u = (x - mu)/sigmaandz = (lam*sigma - u)/sqrt(2)andsigma = sqrt(sigma2). Usinglog_erfcxkeeps the right tail (largez) from underflowing.
The MLE has no closed form (the score equations couple mu, sigma2, lam), so the estimator uses a method-of-moments fit from the accumulated first three moments, which is consistent and the usual practical choice for the EMG.
- class ExponentiallyModifiedGaussianDistribution(mu, sigma2, lam, name=None, keys=None)[source]
Bases:
SequenceEncodableProbabilityDistributionExponentially-modified Gaussian:
X = N(mu, sigma2) + Exp(rate=lam).- density(x)[source]
Density of the EMG at observation
x(seelog_density).
- log_density(x)[source]
Stable log-density of the EMG at
x.log f(x) = log(lam/2) - 0.5*u^2 + log_erfcx(z)withu = (x - mu)/sigmaandz = (lam*sigma - u)/sqrt(2).
- seq_ld_lambda()[source]
Return vectorized log-density callables for encoded data.
- seq_log_density(x)[source]
Vectorized EMG log-density at sequence-encoded input
x.
- classmethod compute_capabilities()[source]
Declare NumPy/Torch scoring capabilities for EMG log-density kernels.
- backend_seq_log_density(x, engine)[source]
Engine-neutral vectorized EMG log-density for encoded data.
- cdf(x)[source]
Cumulative distribution function
P(X <= x)(exact, via scipy’s exponnorm).
- sampler(seed=None)[source]
Return an ExponentiallyModifiedGaussianSampler for this distribution.
- Parameters:
seed (int | None)
- Return type:
ExponentiallyModifiedGaussianSampler
- estimator(pseudo_count=None)[source]
Return an ExponentiallyModifiedGaussianEstimator (method-of-moments).
- Parameters:
pseudo_count (float | None)
- Return type:
ExponentiallyModifiedGaussianEstimator
- dist_to_encoder()[source]
Return the encoder for exponentially modified Gaussian observations.
- Return type:
ExponentiallyModifiedGaussianDataEncoder
- class ExponentiallyModifiedGaussianSampler(dist, seed=None)[source]
Bases:
DistributionSamplerSample an EMG by adding independent Gaussian and exponential draws.
- Parameters:
dist (ExponentiallyModifiedGaussianDistribution)
seed (int | None)
- class ExponentiallyModifiedGaussianAccumulator(keys=None, name=None)[source]
Bases:
SequenceEncodableStatisticAccumulatorAccumulate weighted central moments for method-of-moments EMG estimation.
- update(x, weight, estimate)[source]
Update weighted central moments from one observation.
- initialize(x, weight, rng)[source]
Initialize weighted central moments from one observation.
- Parameters:
x (float)
weight (float)
rng (RandomState | None)
- Return type:
None
- seq_initialize(x, weights, rng)[source]
Initialize weighted central moments from encoded observations.
- Parameters:
x (ndarray)
weights (ndarray)
rng (RandomState | None)
- Return type:
None
- seq_update(x, weights, estimate)[source]
Update weighted central moments from encoded observations.
- combine(suff_stat)[source]
Merge another accumulator’s central-moment summary.
- value()[source]
Return count, mean, second central moment, and third central moment.
- from_value(x)[source]
Restore count and central-moment state from
valueoutput.
- scale(c)[source]
Scale the weighted moment summary by a constant.
- Parameters:
c (float)
- Return type:
ExponentiallyModifiedGaussianAccumulator
- key_merge(stats_dict)[source]
Merge this accumulator into
stats_dictunder its configured key.
- key_replace(stats_dict)[source]
Replace this accumulator’s state from keyed statistics when present.
- acc_to_encoder()[source]
Return the encoder compatible with EMG moment statistics.
- Return type:
ExponentiallyModifiedGaussianDataEncoder
- class ExponentiallyModifiedGaussianAccumulatorFactory(name=None, keys=None)[source]
Bases:
StatisticAccumulatorFactoryCreate EMG central-moment accumulators.
- make()[source]
Create an empty EMG accumulator.
- Return type:
ExponentiallyModifiedGaussianAccumulator
- class ExponentiallyModifiedGaussianEstimator(name=None, keys=None)[source]
Bases:
ParameterEstimatorEstimate EMG parameters from weighted central moments.
- accumulator_factory()[source]
Return a factory for EMG central-moment accumulators.
- Return type:
ExponentiallyModifiedGaussianAccumulatorFactory