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: SequenceEncodableProbabilityDistribution

Skew-normal distribution with location loc, scale > 0 and shape alpha.

Parameters:
density(x)[source]

Return the probability density at a single observation.

Parameters:

x (float)

Return type:

float

log_density(x)[source]

Return the log-density at a single observation.

Parameters:

x (float)

Return type:

float

seq_log_density(x)[source]

Return vectorized log-density values for sequence-encoded observations.

Parameters:

x (ndarray)

Return type:

ndarray

classmethod compute_capabilities()[source]

Describe backend support for generated skew-normal scoring kernels.

backend_seq_log_density(x, engine)[source]

Engine-neutral vectorized skew-normal log-density for encoded data.

Parameters:
Return type:

Any

cdf(x)[source]

Cumulative distribution function P(X <= x) (exact).

Parameters:

x (float)

Return type:

float

quantile(q)[source]

Inverse CDF F^{-1}(q).

Parameters:

q (float)

Return type:

float

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, scale and shape.

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: DistributionSampler

Draw observations as xi + omega (delta |Z0| + sqrt(1-delta^2) Z1) with Z0, Z1 standard normal.

Parameters:
  • dist (SkewNormalDistribution)

  • seed (int | None)

sample(size=None)[source]

Draw one sample or an array of iid samples.

Parameters:

size (int | None)

Return type:

float | ndarray

class SkewNormalAccumulator(name=None, keys=None)[source]

Bases: SequenceEncodableStatisticAccumulator

Accumulate weighted central moments for skew-normal estimation.

The sufficient statistic is stored as (count, mean, M2, M3) where M2 = sum_i w_i (x_i - mean)^2 and M3 = sum_i w_i (x_i - mean)^3 are the weighted central moments. This is mathematically equivalent to the raw power sums (sum x, sum x^2, sum x^3) but avoids the catastrophic E[x^2] - E[x]^2 cancellation 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.

Parameters:
  • name (str | None)

  • keys (str | None)

update(x, weight, estimate)[source]

Accumulate a single weighted observation into central moments.

Parameters:
  • x (float)

  • weight (float)

  • estimate (SkewNormalDistribution | None)

Return type:

None

initialize(x, weight, rng)[source]

Initialize statistics from one observation.

Parameters:
Return type:

None

seq_update(x, weights, estimate)[source]

Accumulate weighted central moments from encoded observations.

Parameters:
  • x (ndarray)

  • weights (ndarray)

  • estimate (SkewNormalDistribution | None)

Return type:

None

seq_initialize(x, weights, rng)[source]

Initialize statistics from encoded observations.

Parameters:
Return type:

None

combine(suff_stat)[source]

Merge another central-moment statistic tuple.

Parameters:

suff_stat (tuple[float, float, float, float])

Return type:

SkewNormalAccumulator

value()[source]

Return count, mean, second central moment sum, and third central moment sum.

Return type:

tuple[float, float, float, float]

from_value(x)[source]

Replace accumulator contents from a central-moment statistic tuple.

Parameters:

x (tuple[float, float, float, float])

Return type:

SkewNormalAccumulator

scale(c)[source]

Scale weight-linear statistics while preserving the weighted mean.

Parameters:

c (float)

Return type:

SkewNormalAccumulator

key_merge(stats_dict)[source]

Merge keyed statistics into stats_dict when keys are configured.

Parameters:

stats_dict (dict[str, Any])

Return type:

None

key_replace(stats_dict)[source]

Replace this accumulator from keyed statistics when available.

Parameters:

stats_dict (dict[str, Any])

Return type:

None

acc_to_encoder()[source]

Return the encoder used by this accumulator.

Return type:

SkewNormalDataEncoder

class SkewNormalAccumulatorFactory(name=None, keys=None)[source]

Bases: StatisticAccumulatorFactory

Factory for SkewNormalAccumulator.

Parameters:
  • name (str | None)

  • keys (str | None)

make()[source]

Create a fresh skew-normal accumulator.

Return type:

SkewNormalAccumulator

class SkewNormalEstimator(min_scale=1.0e-12, name=None, keys=None)[source]

Bases: ParameterEstimator

Method-of-moments estimator for skew-normal location, scale and shape.

Parameters:
  • min_scale (float)

  • name (str | None)

  • keys (str | None)

accumulator_factory()[source]

Return an accumulator factory for skew-normal moment statistics.

Return type:

SkewNormalAccumulatorFactory

estimate(nobs, suff_stat)[source]

Estimate location, scale, and shape from weighted central moments.

Parameters:
Return type:

SkewNormalDistribution

class SkewNormalDataEncoder[source]

Bases: DataSequenceEncoder

Encode skew-normal observations as a float array.

seq_encode(x)[source]

Encode observations as a floating-point array.

Parameters:

x (Sequence[float])

Return type:

ndarray