Coder Social home page Coder Social logo

segmentation-fault / bivariate-sampling Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 15 KB

Python implementation to generate samples from a bivariate continuous distribution

License: GNU General Public License v3.0

Python 100.00%
statistics python35 numerical-methods

bivariate-sampling's Introduction

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).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.