mixle.stats.multivariate._copula_common module¶
Shared plumbing for the non-elliptical copula cores (Clayton, Frank, Student-t).
Unlike the Gaussian copula – whose inversion estimator has an additive sufficient statistic (the moments of
the normal scores) – these cores fit their parameter(s) by Kendall’s-tau matching or 1-D MLE, neither of
which is a running additive statistic. So their accumulator simply BUFFERS the (weighted) uniform scores and
the estimator fits from the whole buffer, the same buffer-the-rows pattern the neural leaves and
CopulaDistribution use. A copula core’s seq_encode returns the raw
u rows (its seq_log_density recomputes whatever transform it needs, since the parameters are not known
at encode time), so the buffered statistic is exactly the (u, weight) rows.
- class UScoreEncoder[source]
Bases:
DataSequenceEncoderEncode a batch of uniform-score rows as a plain
(n, d)float array (identity transform).
- class BufferedUScoreAccumulator(dim, keys=None)[source]
Bases:
SequenceEncodableStatisticAccumulatorBuffer the (weighted) uniform-score rows; the copula core’s estimator fits from the whole buffer.
- update(x, weight, estimate)[source]
Accumulate one weighted observation under an optional current estimate.
- initialize(x, weight, rng)[source]
Initialize sufficient statistics from one weighted observation.
- seq_update(x, weights, estimate)[source]
Accumulate weighted sufficient statistics from sequence-encoded observations.
- seq_initialize(x, weights, rng)[source]
Initialize sufficient statistics from sequence-encoded observations.
- combine(suff_stat)[source]
Merge serialized sufficient statistics into this accumulator.
- value()[source]
Return this accumulator’s serialized sufficient statistics.
- from_value(x)[source]
Restore this accumulator from serialized sufficient statistics.
- 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 a sequence encoder compatible with this accumulator.
- Return type:
UScoreEncoder
- class BufferedUScoreAccumulatorFactory(dim, keys=None)[source]
Bases:
StatisticAccumulatorFactory- make()[source]
Create a fresh accumulator instance.
- Return type:
BufferedUScoreAccumulator
- weighted_kendall_tau(a, b, w)[source]
Weighted Kendall’s tau between two score vectors: (concordant - discordant) / total, pair weight w_i w_j.
O(n^2) over the buffered rows – copula cores are fit on the whole buffer, and n is a batch, not a stream.