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: DataSequenceEncoder

Encode a batch of uniform-score rows as a plain (n, d) float array (identity transform).

seq_encode(x)[source]

Encode the iid observation sequence x for vectorized evaluation.

Parameters:

x (Sequence[ndarray])

Return type:

ndarray

class BufferedUScoreAccumulator(dim, keys=None)[source]

Bases: SequenceEncodableStatisticAccumulator

Buffer the (weighted) uniform-score rows; the copula core’s estimator fits from the whole buffer.

Parameters:
update(x, weight, estimate)[source]

Accumulate one weighted observation under an optional current estimate.

Parameters:
Return type:

None

initialize(x, weight, rng)[source]

Initialize sufficient statistics from one weighted observation.

Parameters:
Return type:

None

seq_update(x, weights, estimate)[source]

Accumulate weighted sufficient statistics from sequence-encoded observations.

Parameters:
Return type:

None

seq_initialize(x, weights, rng)[source]

Initialize sufficient statistics from sequence-encoded observations.

Parameters:
Return type:

None

combine(suff_stat)[source]

Merge serialized sufficient statistics into this accumulator.

Parameters:

suff_stat (tuple[ndarray, ndarray])

Return type:

BufferedUScoreAccumulator

value()[source]

Return this accumulator’s serialized sufficient statistics.

Return type:

tuple[ndarray, ndarray]

from_value(x)[source]

Restore this accumulator from serialized sufficient statistics.

Parameters:

x (tuple[ndarray, ndarray])

Return type:

BufferedUScoreAccumulator

key_merge(stats_dict)[source]

Pool this accumulator’s statistics into stats_dict under its merge key.

The structural default implements the common single-key pattern: store the accumulator under self.keys the first time the key is seen, else combine into 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. A keys of None (the default) is a no-op.

Parameters:

stats_dict (dict[str, Any])

Return type:

None

key_replace(stats_dict)[source]

Replace this accumulator’s statistics from the pooled stats_dict entry (see key_merge).

Parameters:

stats_dict (dict[str, Any])

Return type:

None

acc_to_encoder()[source]

Return a sequence encoder compatible with this accumulator.

Return type:

UScoreEncoder

class BufferedUScoreAccumulatorFactory(dim, keys=None)[source]

Bases: StatisticAccumulatorFactory

Parameters:
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.

Parameters:
Return type:

float

maximize_1d(loglik, lo, hi, *, iters=60)[source]

Golden-section search for the argmax of a unimodal 1-D loglik on [lo, hi].

Parameters:
Return type:

float