0

Suppose I am given a CDF of a distribution, given by $F(x) \propto x + x^2 + x^4 + x^7$. How do I generate a random variable from this distribution?

Clarinetist
  • 19,519

1 Answers1

1

As clarinetist wrote, your CDF is not really well-defined. But I will go ahead and assume its support lies on an interval of the form $[0,a]$, i.e. $F(0)=0$ and $F(a)=1$. Then $F:[0,a] \to [0,1]$ is bijective (since it is a sum of monomial terms with coefficients equal to 1) and hence $F^{-1}$ is well-defined.

Now let $V \sim U[0,1]$ be a uniformly distributed random variable, then by the inverse probability integral transformation it holds that:

$$ F^{-1}(V) \sim F $$

In other words, you can generate your random variable $X$ as follows:

Step 1: Draw $V \sim U[0,1]$

Step 2: Let $X=F^{-1}(V)$ (e.g. by inverting $F$ numerically)

air
  • 2,812
  • but my problem is that I can't invert this F ! :(

    How will I do it ? :(

    – Dwaipayan Gupta Sep 03 '15 at 05:48
  • Well you want to do this numerically right? Then you need to solve the equation $F(X)=V$ to get your random variable $X$. This is easy since it is a 1-dimensional problem and has a unique solution, so you can use the bisection method for example (https://en.wikipedia.org/wiki/Bisection_method). – air Sep 03 '15 at 12:24