Generate random values using an empirical cumulative distribution function

120 Views Asked by At

I have a set of data points that I have used to generate my empirical cumulative distribution function (CDF), which looks like this (to simplify things I have reduced the number of points for this question but it shouldn't matter):

CDF

Given this data and plot, I need to somehow generate random values which follow this distribution. I admit that I am quite rusty when it comes to probability, but as far as I understand I need to first generate the probability density function (PDF), and then from there I can do what I want. Is that accurate? Or what is the best way to get what I want?

If interested in giving an example for the answer, here are the X and Y array for the data points of the ECDF plot. I am using Python but I guess a language agnostic answer would also be really helpful

x = [107.6697676209896, 430.70331251794784, 1975.0646306785532, 7793.524079329409, 27569.66699567533, 62566.73646946178, 222847.1449910263, 832591.8949493016, 2827054.7454871265, 10000733.572934577]
y = [0, 0.04812202549318534, 0.09825964339269633, 0.14190143419466905, 0.27204351414405636, 0.46590411495145756, 0.6008552899988212, 0.6796719668120879, 0.8400864397710662, 1]

Thanks a lot!

1

There are 1 best solutions below

1
On

Recall that for any CDF $F(t)$, let $F^{-1}(x):=\inf\{t:F(t)\geq x\}$, then given $U\sim Unif[0,1]$, $F^{-1}(U)$ has CDF $F(t)$.