mixle.stats.directional.wrapped_cauchy module¶
Wrapped Cauchy distribution – a heavy-tailed circular law on angles.
Wrapping a Cauchy around the circle gives the wrapped Cauchy, the circular analogue of the Cauchy and
a heavier-tailed alternative to the von Mises. With mean direction mu and mean-resultant length
rho in [0, 1),
f(theta; mu, rho) = (1 - rho^2) / (2 pi (1 + rho^2 - 2 rho cos(theta - mu))),
uniform on the circle at rho = 0 and increasingly peaked at mu as rho -> 1. Its first
trigonometric moment is exactly rho e^{i mu}, so the mean direction and concentration are estimated
in closed form from the mean resultant (the circular analogue of the sample mean). It samples exactly:
rho corresponds to wrapping a Cauchy of scale gamma = -log rho.
Reference: Mardia & Jupp, Directional Statistics (Wiley, 2000).
- class WrappedCauchyDistribution(mu, rho, name=None, keys=None)[source]
Bases:
SequenceEncodableProbabilityDistributionWrapped Cauchy distribution with mean direction
muand concentrationrhoin[0, 1).- density(x)[source]
Return the probability density at a single angle (radians).
- log_density(x)[source]
Return the log-density at a single angle (radians).
- seq_log_density(x)[source]
Return vectorized log-density values for sequence-encoded
(cos, sin)observations.
- classmethod compute_capabilities()[source]
Describe backend support for generated wrapped-Cauchy kernels.
- classmethod compute_declaration()[source]
Return the structured compute declaration for wrapped Cauchy distributions.
- static backend_legacy_sufficient_statistics(x, params, engine)[source]
Per-row circular moments in accumulator order
(sum_cos, sum_sin, count).
- static backend_log_density_from_params(cos_t, sin_t, cos_mu, sin_mu, rho, engine)[source]
Engine-neutral wrapped-Cauchy log-density from pre-computed observation/parameter trig.
- backend_seq_log_density(x, engine)[source]
Engine-neutral vectorized log-density for encoded
(cos, sin)data.
- classmethod backend_stacked_params(dists, engine)[source]
Stacked wrapped-Cauchy parameters (trig computed host-side) for a homogeneous mixture kernel.
- classmethod backend_stacked_log_density(x, params, engine)[source]
Return an
(n, k)matrix of wrapped-Cauchy log densities.
- classmethod backend_stacked_sufficient_statistics(x, weights, params, engine)[source]
Stacked circular moments
(sum_cos, sum_sin, count)using engine-resident arrays.
- sampler(seed=None)[source]
Return a sampler for drawing angles from this distribution.
- Parameters:
seed (int | None)
- Return type:
WrappedCauchySampler
- estimator(pseudo_count=None)[source]
Return a closed-form (mean-resultant) estimator for
muandrho.- Parameters:
pseudo_count (float | None)
- Return type:
WrappedCauchyEstimator
- dist_to_encoder()[source]
Return the data encoder used by this distribution (cos/sin of the angle).
- Return type:
WrappedCauchyDataEncoder
- class WrappedCauchySampler(dist, seed=None)[source]
Bases:
DistributionSamplerDraw angles by wrapping a Cauchy of scale
-log rhoaround the circle.- Parameters:
dist (WrappedCauchyDistribution)
seed (int | None)
- class WrappedCauchyAccumulator(name=None, keys=None)[source]
Bases:
SequenceEncodableStatisticAccumulatorAccumulate the weighted circular resultant
(sum cos, sum sin, count).- update(x, weight, estimate)[source]
Accumulate one weighted circular resultant contribution.
- initialize(x, weight, rng)[source]
Initialize statistics from one angle.
- Parameters:
x (float)
weight (float)
rng (RandomState | None)
- Return type:
None
- seq_update(x, weights, estimate)[source]
Accumulate circular-resultant statistics from encoded cos/sin values.
- seq_initialize(x, weights, rng)[source]
Initialize statistics from encoded angles.
- Parameters:
weights (ndarray)
rng (RandomState | None)
- Return type:
None
- combine(suff_stat)[source]
Merge another wrapped-Cauchy sufficient-statistic tuple.
- value()[source]
Return cosine sum, sine sum, and total weight.
- from_value(x)[source]
Replace accumulator contents from circular-resultant 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:
WrappedCauchyDataEncoder
- class WrappedCauchyAccumulatorFactory(name=None, keys=None)[source]
Bases:
StatisticAccumulatorFactoryFactory for WrappedCauchyAccumulator.
- make()[source]
Create a fresh wrapped-Cauchy accumulator.
- Return type:
WrappedCauchyAccumulator
- class WrappedCauchyEstimator(rho_max=1.0 - 1.0e-8, name=None, keys=None)[source]
Bases:
ParameterEstimatorEstimate
muandrhofrom the mean resultant (the first trigonometric moment).- accumulator_factory()[source]
Return an accumulator factory for circular-resultant statistics.
- Return type:
WrappedCauchyAccumulatorFactory