mixle.stats.directional.watson module¶
Watson distribution – a rotationally symmetric distribution for axial data on the sphere.
Axial data are unit vectors identified with their antipodes (x and -x are the same), e.g. fibre
or crystal orientations, where the von Mises-Fisher (which distinguishes x from -x) does not
apply. The Watson distribution on S^{p-1} concentrates around an axis mu with shape kappa:
f(x; mu, kappa) = M(1/2, p/2, kappa)^{-1} / omega_p * exp(kappa (mu^T x)^2),
where M is Kummer’s confluent hypergeometric function and omega_p = 2 pi^{p/2} / Gamma(p/2) is
the sphere’s surface area. kappa > 0 is bipolar (mass near the axis +/-mu), kappa < 0
girdle (mass on the equator orthogonal to mu); both are antipodally symmetric. It is fit by maximum
likelihood: mu is the leading (kappa>0) or trailing (kappa<0) eigenvector of the scatter matrix,
and kappa solves E[(mu^T x)^2] = mu^T S mu (a monotone 1-D equation in the Kummer ratio).
Reference: Mardia & Jupp, Directional Statistics (Wiley, 2000).
- class WatsonDistribution(mu, kappa, name=None, keys=None)[source]
Bases:
SequenceEncodableProbabilityDistributionWatson distribution on the unit sphere
S^{p-1}with axismuand concentrationkappa.- density(x)[source]
Return the density at a single unit vector
x.
- log_density(x)[source]
Return the log-density at a single unit vector
x.
- seq_log_density(x)[source]
Vectorized log-density for a stack of unit vectors, shape
(N, p).
- classmethod compute_capabilities()[source]
- backend_seq_log_density(x, engine)[source]
Engine-neutral vectorized log-density for
(N, p)unit vectors.
- sampler(seed=None)[source]
Return a sampler for drawing unit vectors from this distribution.
- Parameters:
seed (int | None)
- Return type:
WatsonSampler
- estimator(pseudo_count=None)[source]
Return a maximum-likelihood estimator (scatter eigenvector + Kummer-ratio kappa solve).
- Parameters:
pseudo_count (float | None)
- Return type:
WatsonEstimator
- dist_to_encoder()[source]
Return the data encoder used by this distribution for vectorized methods.
- Return type:
WatsonDataEncoder
- class WatsonSampler(dist, seed=None)[source]
Bases:
DistributionSamplerDraw axes by sampling
s = |mu^T x|via a numerical inverse-CDF, then a random orthogonal tangent.- Parameters:
dist (WatsonDistribution)
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 WatsonAccumulator(dim, name=None, keys=None)[source]
Bases:
SequenceEncodableStatisticAccumulatorAccumulate the weighted scatter matrix
S = sum_i w_i x_i x_i^Tand total weight.- update(x, weight, estimate)[source]
- initialize(x, weight, rng)[source]
- Parameters:
x (ndarray)
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]
- 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:
WatsonDataEncoder
- class WatsonAccumulatorFactory(dim, name=None, keys=None)[source]
Bases:
StatisticAccumulatorFactoryFactory for WatsonAccumulator.
- make()[source]
- Return type:
WatsonAccumulator