Skip to content

Python implementation to generate samples from a bivariate continuous distribution

License

Notifications You must be signed in to change notification settings

segmentation-fault/bivariate-sampling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages