100 Days of ML Day 117 - Sampling from Distributions using Universal Law of Standard Uniform
100 Days of ML Day 117
Sampling from Distributions using Universal Law of Standard Uniform
Wrote code to generate and visualize a random sample from a distribution with a known CDF by sampling from a Standard Uniform Distribution and applying Universal Law.The law states that if F is the cdf of the distribution from which we want to draw samples. Then X=F-1(U) has cdf F.
(Read F-1 as 'F-inverse'. I'll figure out how to latex soon)
We generate a bunch of numbers from Uniform(0,1) distribution and then making the F-1 transformation on these numbers to get random numbers from the distribution we desire. I've illustrated it using plots.
Code:
https://github.com/hithesh111/HithBeyond100/blob/master/Days/day117.ipynb
No comments