mixle.stats.univariate.continuous.generalized_gaussian module¶
Generalized Gaussian (exponential-power) distribution.
A symmetric location-scale family with a tunable tail/peakedness shape beta that interpolates the
Laplace (beta = 1), Gaussian (beta = 2), and uniform (beta -> inf) laws. With location
mu, scale alpha > 0 and shape beta > 0,
f(x; mu, alpha, beta) = beta / (2 alpha Gamma(1/beta)) * exp(-(|x - mu| / alpha)^beta).
The normalizer is closed form (a Gamma function), so density/CDF/quantile/moments/entropy are all exact;
it samples exactly via a Gamma draw with a random sign. Parameters are fit by the method of moments:
mu is the mean, the excess kurtosis Gamma(5/beta)Gamma(1/beta)/Gamma(3/beta)^2 - 3 pins beta
(monotone, solved by a bracketed root find), and alpha follows from the variance
alpha^2 Gamma(3/beta)/Gamma(1/beta).
References
Nadarajah, “A generalized normal distribution”, J. Applied Statistics 32 (2005).
Subbotin (1923), the original exponential-power family.
- class GeneralizedGaussianDistribution(mu, alpha, beta, name=None, keys=None)[source]
Bases:
SequenceEncodableProbabilityDistributionGeneralized Gaussian (exponential power) with location
mu, scalealphaand shapebeta.- classmethod compute_declaration()[source]
- static backend_log_density_from_params(x, mu, alpha, beta, engine)[source]
Engine-neutral generalized-Gaussian log-density: log_norm - (|x-mu|/alpha)**beta.
- seq_log_density(x)[source]
Return vectorized log-density for a sequence-encoded array of observations.
- kurtosis()[source]
Excess kurtosis Gamma(5/beta)Gamma(1/beta)/Gamma(3/beta)^2 - 3.
- Return type:
- entropy()[source]
Differential entropy 1/beta - log(beta / (2 alpha Gamma(1/beta))).
- Return type:
- sampler(seed=None)[source]
Return a sampler (Gamma magnitude with a random sign).
- Parameters:
seed (int | None)
- Return type:
GeneralizedGaussianSampler
- estimator(pseudo_count=None)[source]
Return a method-of-moments estimator for
mu,alpha,beta.- Parameters:
pseudo_count (float | None)
- Return type:
GeneralizedGaussianEstimator
- dist_to_encoder()[source]
Return the data encoder used by this distribution (the raw value).
- Return type:
GeneralizedGaussianDataEncoder
- class GeneralizedGaussianSampler(dist, seed=None)[source]
Bases:
DistributionSamplerDraw
x = mu + sign * alpha * Gamma(1/beta)**(1/beta).- Parameters:
dist (GeneralizedGaussianDistribution)
seed (int | None)
- sample(size=None)[source]
Draw observations.
Combinator samplers (mixture/sequence/…) accept
batched. Withbatched=True(the default) each child stream is drawn in one vectorized call instead of a per-draw Python loop – far faster. Because every child sampler owns an independentRandomState, batching consumes each stream in the same order as the loop, so the draws are identical to the legacy path.batched=Falseforces that legacy per-draw loop as a guaranteed- stable reference. Leaf samplers are already vectorized and ignore the flag.
- class GeneralizedGaussianAccumulator(name=None, keys=None)[source]
Bases:
SequenceEncodableStatisticAccumulatorAccumulate the weighted power sums
(count, sum x, sum x^2, sum x^3, sum x^4)for the MoM.- update(x, weight, estimate)[source]
- initialize(x, weight, rng)[source]
- Parameters:
x (float)
weight (float)
rng (RandomState | None)
- Return type:
None
- seq_update(x, weights, estimate)[source]
- seq_initialize(x, weights, rng)[source]
- Parameters:
x (ndarray)
weights (ndarray)
rng (RandomState | None)
- Return type:
None
- combine(suff_stat)[source]
- from_value(x)[source]
- key_merge(stats_dict)[source]
Pool this accumulator’s statistics into
stats_dictunder its merge key.The structural default implements the common single-key pattern: store the accumulator under
self.keysthe first time the key is seen, elsecombineinto the one already there. Accumulators with several named keys (e.g. an HMM’s init/trans/state keys) or a non-accumulator stats payload override this. AkeysofNone(the default) is a no-op.
- key_replace(stats_dict)[source]
Replace this accumulator’s statistics from the pooled
stats_dictentry (see key_merge).
- acc_to_encoder()[source]
- Return type:
GeneralizedGaussianDataEncoder
- class GeneralizedGaussianAccumulatorFactory(name=None, keys=None)[source]
Bases:
StatisticAccumulatorFactoryFactory for GeneralizedGaussianAccumulator.
- make()[source]
- Return type:
GeneralizedGaussianAccumulator