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]
Describe backend support for generated Watson scoring kernels.
- 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)
- 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]
Accumulate one weighted outer product into the scatter matrix.
- initialize(x, weight, rng)[source]
Initialize statistics from one unit vector.
- Parameters:
x (ndarray)
weight (float)
rng (RandomState | None)
- Return type:
None
- seq_update(x, weights, estimate)[source]
Accumulate weighted scatter statistics from encoded unit vectors.
- seq_initialize(x, weights, rng)[source]
Initialize statistics from encoded unit vectors.
- Parameters:
x (ndarray)
weights (ndarray)
rng (RandomState | None)
- Return type:
None
- combine(suff_stat)[source]
Merge another Watson sufficient-statistic tuple.
- from_value(x)[source]
Replace accumulator contents from scatter statistics.
- key_merge(stats_dict)[source]
Merge keyed statistics into
stats_dictwhen keys are configured.
- key_replace(stats_dict)[source]
Replace this accumulator from keyed statistics when available.
- acc_to_encoder()[source]
Return the encoder used by this accumulator.
- Return type:
WatsonDataEncoder
- class WatsonAccumulatorFactory(dim, name=None, keys=None)[source]
Bases:
StatisticAccumulatorFactoryFactory for WatsonAccumulator.
- make()[source]
Create a fresh Watson accumulator.
- Return type:
WatsonAccumulator
- class WatsonEstimator(dim, name=None, keys=None)[source]
Bases:
ParameterEstimatorMaximum-likelihood estimator: scatter eigenvector for the axis, Kummer-ratio solve for kappa.
- accumulator_factory()[source]
Return an accumulator factory for Watson scatter statistics.
- Return type:
WatsonAccumulatorFactory