segmentation-fault / bivariate-sampling

Python implementation to generate samples from a bivariate continuous distribution

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bivariate-sampling

Python implementation to generate samples from a bivariate continuous distribution

Some theory

For a univariate distribution with CDF equation , we can generate a sample from said distribution via the inverse sampling theorem; if the random variable U is drawn from a uniform distribution between 0 and 1, then a realization of the random variable X is:

equation ,

or, the inverse of the CDF of X calculated in a random outcome of the uniform distribution between 0 and 1.

For a bivariate distribution with CDF equation, we can approximate the generation of two samples by following those two steps:

  • Generate a sample from X with the Inverse sampling theorem, using the marginal CDF equation
  • Then, generate a sample of Y by using the conditional CDF of Y given that X=x, i.e.

equation .

In case the marginal is not readily available, one can calculate it as:

equation .

In practice this means calculating the Joint CDF at a very high value of y (in my code I used 1e5).

About

Python implementation to generate samples from a bivariate continuous distribution

License:GNU General Public License v3.0


Languages

Language:Python 100.0%