Univariate Distributions

All the examples in the introduction focused exclusively on the Normal (or Gaussian) Distribution over a single random variable, but lots of other univariate distributions exist.

The Copulas library supports several of them through the Univariate subclasses defined within the copulas.univariate package:

  • copulas.univariate.BetaUnivariate: Implements a Beta distribution.

  • copulas.univariate.GammaUnivariate: Implements a Gamma distribution.

  • copulas.univariate.GaussianKDE: Implements a Kernel-Density Estimate using a Gaussian kernel.

  • copulas.univariate.GaussianUnivariate: Implements a Gaussian (or Normal) distribution.

  • copulas.univariate.TruncatedGaussian: Implements a Truncated Gaussian distribution.

Let’s explore an example of how to use a Univariate subclass.

Univariate Usage Example

In this example we will be focusing on the BetaUnivariate class, which implements a Beta Distribution.

This distribution is parameterized by two positive shape parameters, \(α\) and \(β\), which in our implementation are called \(a\) and \(b\).

Additionally, our implementation also uses the same loc and scale arguments as the underlying scipy.stats.beta model that we are using.

For this example, we will be using a simulated dataset that follows the beta distribution with parameters \(a = 3\), \(b = 1\), \(loc = 4\) and \(scale = 1\).

from copulas.datasets import sample_univariate_beta

data = sample_univariate_beta()
0    4.796025
1    4.935189
2    4.637677
3    4.945320
4    4.726815
dtype: float64
from copulas.visualization import dist_1d