mixle.stats.univariate.continuous.skew_normal module¶
Skew-normal distribution – a Gaussian with an asymmetry (shape) parameter.
The skew-normal extends the normal with a shape alpha that tilts the density without bounding it:
f(x) = (2 / omega) phi((x - xi) / omega) Phi(alpha (x - xi) / omega),
with location xi, scale omega > 0 and shape alpha (alpha = 0 recovers the normal, the
sign of alpha sets the direction of skew). It samples exactly from two standard normals, and is fit
by method of moments: the sample skewness fixes alpha through the monotone skewness-vs-shape
relation, then the variance fixes omega and the mean fixes xi.
Reference: Azzalini, ‘A class of distributions which includes the normal ones’, Scand. J. Statist. (1985).
- class SkewNormalDistribution(loc, scale, shape, name=None, keys=None)[source]
Bases:
SequenceEncodableProbabilityDistributionSkew-normal distribution with location
loc, scale> 0and shapealpha.- density(x)[source]
Return the probability density at a single observation.
- log_density(x)[source]
Return the log-density at a single observation.
- seq_log_density(x)[source]
Return vectorized log-density values for sequence-encoded observations.
- classmethod compute_capabilities()[source]
- backend_seq_log_density(x, engine)[source]
Engine-neutral vectorized skew-normal log-density for encoded data.
- cdf(x)[source]
Cumulative distribution function
P(X <= x)(exact).
- sampler(seed=None)[source]
Return a sampler for drawing observations from this distribution.
- Parameters:
seed (int | None)
- Return type:
SkewNormalSampler
- estimator(pseudo_count=None)[source]
Return a method-of-moments estimator for
loc,scaleandshape.- Parameters:
pseudo_count (float | None)
- Return type:
SkewNormalEstimator
- dist_to_encoder()[source]
Return the data encoder used by this distribution for vectorized methods.
- Return type:
SkewNormalDataEncoder
- class SkewNormalSampler(dist, seed=None)[source]
Bases:
DistributionSamplerDraw observations as
xi + omega (delta |Z0| + sqrt(1-delta^2) Z1)withZ0, Z1standard normal.- Parameters:
dist (SkewNormalDistribution)
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 SkewNormalAccumulator(name=None, keys=None)[source]
Bases:
SequenceEncodableStatisticAccumulatorAccumulate weighted central moments for skew-normal estimation.
The sufficient statistic is stored as
(count, mean, M2, M3)whereM2 = sum_i w_i (x_i - mean)^2andM3 = sum_i w_i (x_i - mean)^3are the weighted central moments. This is mathematically equivalent to the raw power sums(sum x, sum x^2, sum x^3)but avoids the catastrophicE[x^2] - E[x]^2cancellation when|mean|is large relative to the spread: each batch is centered on its own mean before squaring/cubing, and batches merge through the Pébay/West parallel-moment formulas (exact for real weights). SkewNormal is a host-only leaf (no exponential-family / engine-resident path), so changing the accumulator representation has no engine-swap parity implications.- 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]
- scale(c)[source]
Scale linear sufficient statistics in-place by
c.The structural default is correct for ordinary weighted sums, nested tuples/lists/dicts, and numeric arrays. Families whose
value()payload includes non-linear metadata such as support bounds must override this method and leave that metadata unscaled.- Parameters:
c (float)
- Return type:
SkewNormalAccumulator
- 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:
SkewNormalDataEncoder
- class SkewNormalAccumulatorFactory(name=None, keys=None)[source]
Bases:
StatisticAccumulatorFactoryFactory for SkewNormalAccumulator.
- make()[source]
- Return type:
SkewNormalAccumulator