Generating random samples from a probability distribution function

94 Views Asked by At

I am trying to generate a random sample from the distribution (PDF) of the form $x^2 e^{-x^2}$. I am using MATLAB. One method suggested was to find the CDF and equate $CDF(x) = U$. Then solve for $x$ in terms of $U$ and set U to be a uniform distribution (MATLAB can easily sample using 'rand' function). Then $x$ forms the required distribution. However, I don't know how to integrate $x^2 e^{-x^2}$ to get the CDF. Alternatively, could you please suggest an alternative method in MATLAB if it exists.