mixle.stats.univariate.discrete.skellam module¶
Skellam distributions for differences of independent Poisson counts.
- Data type (int):
K = N1 - N2withN1 ~ Poisson(mu1),N2 ~ Poisson(mu2)independent, so Kranges over all integers (negative, zero, positive). Its log-mass islog p(k) = -(sqrt(mu1) - sqrt(mu2))^2 + (k/2) * log(mu1/mu2) + log(I_|k|(2*sqrt(mu1*mu2))),
where
I_vis the modified Bessel function of the first kind. The exponentially-scaledive(v, z) = I_v(z) * exp(-z)is used (log I_v(z) = log(ive(v, z)) + z) so the Bessel term does not overflow for largez; combined with-(mu1+mu2) + zthis collapses to the stable-(sqrt(mu1) - sqrt(mu2))^2constant above.
The MLE has no closed form, but the method of moments is exact and closed-form here: with sample
mean m and variance v, mu1 = (v + m)/2 and mu2 = (v - m)/2 (since E[K] = mu1-mu2
and Var[K] = mu1+mu2), which the estimator uses (clamped to keep both rates positive).
Reference: Skellam, ‘The frequency distribution of the difference between two Poisson variates’, JRSS A (1946).
- class SkellamDistribution(mu1, mu2, name=None, keys=None)[source]
Bases:
SequenceEncodableProbabilityDistributionSkellam distribution:
K = N1 - N2for independentN1 ~ Poisson(mu1),N2 ~ Poisson(mu2).- density(x)[source]
Probability mass at integer
x(seelog_density).
- log_density(x)[source]
Stable Skellam log-mass at integer
x(-inffor non-integer input).
- seq_log_density(x)[source]
Vectorized Skellam log-mass at sequence-encoded integer counts
x.
- classmethod compute_capabilities()[source]
Describe backend support for generated Skellam scoring kernels.
- backend_seq_log_density(x, engine)[source]
Engine-neutral vectorized Skellam log-mass for encoded data (see class backend note).
The series yields the UNSCALED
log I_k(notlog ive = log I_k - z), so the constant here is-(mu1 + mu2)— the legacy path’s-sqrt_diff_sqplus its implicit-z.
- cdf(x)[source]
Cumulative distribution function P(X <= x) (via scipy skellam).
- quantile(q)[source]
Inverse CDF F^{-1}(q) (via scipy skellam).
- sampler(seed=None)[source]
Return a SkellamSampler for this distribution.
- Parameters:
seed (int | None)
- Return type:
SkellamSampler
- estimator(pseudo_count=None)[source]
Return a SkellamEstimator (method of moments).
- Parameters:
pseudo_count (float | None)
- Return type:
SkellamEstimator
- dist_to_encoder()[source]
Return the encoder for Skellam observations.
- Return type:
SkellamDataEncoder
- class SkellamSampler(dist, seed=None)[source]
Bases:
DistributionSamplerDraw iid Skellam observations as the difference of two independent Poisson draws.
- Parameters:
dist (SkellamDistribution)
seed (int | None)
- class SkellamAccumulator(name=None, keys=None)[source]
Bases:
SequenceEncodableStatisticAccumulatorAccumulate the weighted count, sum, and sum-of-squares needed for the moment fit.
- update(x, weight, estimate)[source]
Accumulate count, sum, and squared sum for one integer observation.
- initialize(x, weight, rng)[source]
Initialize statistics from one observation.
- Parameters:
x (int)
weight (float)
rng (RandomState | None)
- Return type:
None
- seq_update(x, weights, estimate)[source]
Accumulate count, sum, and squared sum from encoded observations.
- seq_initialize(x, weights, rng)[source]
Initialize statistics from encoded observations.
- Parameters:
x (ndarray)
weights (ndarray)
rng (RandomState | None)
- Return type:
None
- combine(suff_stat)[source]
Merge another Skellam sufficient-statistic tuple.
- from_value(x)[source]
Replace accumulator contents from a sufficient-statistic tuple.
- scale(c)[source]
Scale all weight-linear sufficient statistics by
c.- Parameters:
c (float)
- Return type:
SkellamAccumulator
- 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:
SkellamDataEncoder
- class SkellamAccumulatorFactory(name=None, keys=None)[source]
Bases:
StatisticAccumulatorFactoryFactory for SkellamAccumulator.
- make()[source]
Create a fresh Skellam accumulator.
- Return type:
SkellamAccumulator