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?
Asked
Active
Viewed 87 times
0
-
Actually, here's a better question. What is the support of $X$ supposed to be? I would suppose $F$ would be $0$ over some interval and $1$ over some other interval... – Clarinetist Sep 02 '15 at 22:54
-
the support of X is [0,1]. – Dwaipayan Gupta Sep 03 '15 at 05:46
1 Answers
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