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)
- 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]
Accumulate weighted normal-score moments for one copula observation.
- initialize(x, weight, rng)[source]
Initialize the sufficient statistics with one weighted observation.
- Parameters:
x (ndarray)
weight (float)
rng (RandomState | None)
- Return type:
None
- seq_update(x, weights, estimate)[source]
Accumulate weighted moments from encoded normal-score observations.
- seq_initialize(x, weights, rng)[source]
Initialize the sufficient statistics from encoded observations.
- Parameters:
x (ndarray)
weights (ndarray)
rng (RandomState | None)
- Return type:
None
- combine(suff_stat)[source]
Merge serialized normal-score moments into this accumulator.
- value()[source]
Return the weighted first moments, second moments, and total weight.
- from_value(x)[source]
Restore the accumulator from serialized normal-score moments.
- key_merge(stats_dict)[source]
Merge this accumulator into a keyed statistics dictionary.
- key_replace(stats_dict)[source]
Replace this accumulator from a keyed statistics dictionary.
- acc_to_encoder()[source]
Return an encoder that produces normal-score observations.
- Return type:
GaussianCopulaDataEncoder
- class GaussianCopulaAccumulatorFactory(dim, name=None, keys=None)[source]
Bases:
StatisticAccumulatorFactoryFactory for GaussianCopulaAccumulator.
- make()[source]
Create an empty Gaussian copula accumulator.
- Return type:
GaussianCopulaAccumulator
- class GaussianCopulaEstimator(dim, min_eig=1.0e-8, name=None, keys=None)[source]
Bases:
ParameterEstimatorInversion estimator: the correlation of the normal scores
z = Phi^{-1}(u).- accumulator_factory()[source]
Return a factory for Gaussian copula sufficient-statistic accumulators.
- Return type:
GaussianCopulaAccumulatorFactory