mixle.stats.multivariate.gaussian_copula module¶
Gaussian copula: dependence structure on (0,1)^d decoupled from the marginals.
A copula is the joint distribution of U = (F_1(X_1), ..., F_d(X_d)) – each coordinate is its own
marginal CDF, so every marginal is Uniform(0,1) and all that remains is the dependence. The Gaussian
copula puts that dependence in a correlation matrix R: pull each uniform back to a standard normal
z_i = Phi^{-1}(u_i) and let z ~ N(0, R). Its density on (0,1)^d is
c(u) = |R|^{-1/2} exp(-1/2 z^T (R^{-1} - I) z), z = Phi^{-1}(u),
(the Phi Jacobians cancel the standard-normal part of the multivariate normal). Modelling the
dependence separately from the marginals is the whole point of copulas – couple any marginals you
like (fit each separately) through one R. R is fit by the standard inversion estimator: the
sample correlation of the transformed z.
Reference: Nelsen, An Introduction to Copulas (2nd ed., Springer, 2006).
- class GaussianCopulaDistribution(corr, name=None, keys=None)[source]
Bases:
SequenceEncodableProbabilityDistributionGaussian copula on
(0,1)^dwith dependence given by a correlation matrix.- density(x)[source]
Return the copula density at a single point
uin(0,1)^d.
- log_density(x)[source]
Return the log copula density at a single point
uin(0,1)^d.
- seq_log_density(x)[source]
Vectorized log copula density for sequence-encoded observations (
z = Phi^{-1}(u)rows).
- sampler(seed=None)[source]
Return a sampler for drawing observations from this copula.
- Parameters:
seed (int | None)
- Return type:
GaussianCopulaSampler
- estimator(pseudo_count=None)[source]
Return an estimator that fits the correlation matrix by the inversion estimator.
- Parameters:
pseudo_count (float | None)
- Return type:
GaussianCopulaEstimator
- dist_to_encoder()[source]
Return the data encoder (stores the normal-score transform
z = Phi^{-1}(u)).- Return type:
GaussianCopulaDataEncoder
- class GaussianCopulaSampler(dist, seed=None)[source]
Bases:
DistributionSamplerDraw
uby samplingz ~ N(0, R)and mapping through the standard-normal CDF.- Parameters:
dist (GaussianCopulaDistribution)
seed (int | None)
- sample(size=None)[source]
Draw observations.
Combinator samplers (mixture/sequence/…) accept
batched. Withbatched=True(the default) each child stream is drawn in one vectorized call instead of a per-draw Python loop – far faster. Because every child sampler owns an independentRandomState, batching consumes each stream in the same order as the loop, so the draws are identical to the legacy path.batched=Falseforces that legacy per-draw loop as a guaranteed- stable reference. Leaf samplers are already vectorized and ignore the flag.
- class GaussianCopulaAccumulator(dim, name=None, keys=None)[source]
Bases:
SequenceEncodableStatisticAccumulatorAccumulate the weighted first and second moments of the normal scores
z.- update(x, weight, estimate)[source]
- initialize(x, weight, rng)[source]
- Parameters:
x (ndarray)
weight (float)
rng (RandomState | None)
- Return type:
None
- seq_update(x, weights, estimate)[source]
- seq_initialize(x, weights, rng)[source]
- Parameters:
x (ndarray)
weights (ndarray)
rng (RandomState | None)
- Return type:
None
- combine(suff_stat)[source]
- from_value(x)[source]
- 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 type:
GaussianCopulaDataEncoder
- class GaussianCopulaAccumulatorFactory(dim, name=None, keys=None)[source]
Bases:
StatisticAccumulatorFactoryFactory for GaussianCopulaAccumulator.
- make()[source]
- Return type:
GaussianCopulaAccumulator