Multivariate Distributions

Apart from the Univariate distributions, which only work on single random variables, the Copulas library supports several Multivariate distributions that support working with multiple random variables at the same time, taking into account the dependencies that may exist between them.

These distributions are supported by the Multivariate subclasses from defined within the copulas.multivariate package:

  • copulas.multivariate.GaussianMultivariate: Implements a multivariate distribution by combining the marginal univariate distributions with a Gaussian Copula.

  • copulas.multivariate.VineCopula: Implements a multivariate distribution using Vine Copulas.

Gaussian Multivariate

In this example we will be using the GaussianMultivariate class, which implements a multivariate distribution by using a Gaussian Copula to combine marginal probabilities estimated using Univariate distributions.

Firs of all, let’s load the data that we will be using later on in our examples.

This is a toy dataset with three columns following these distributions:

  • x: Beta distribution with a=0.1 and b=0.1

  • y: Beta distribution with a=0.1 and b=0.5

  • z: Normal distribution + 10 times y

[2]:
from copulas.datasets import sample_trivariate_xyz

data = sample_trivariate_xyz()
[3]:
data.head()
[3]:
x y z
0 9.004177e-05 2.883992e-06 0.638689
1 8.819273e-01 2.911979e-07 1.058121
2 5.003865e-01 4.886504e-04 0.372506
3 1.838544e-12 5.392802e-02 0.687370
4 1.627915e-01 1.634269e-08 -0.881068
[4]:
from copulas.visualization import scatter_3d

scatter_3d(data)