Hi there MHF

I've got this problem which I'm stuck on. I'm generating random uniformly distributed numbers between 0 and 1, and I need to transform these numbers into numbers governed by the probability density function

Code:

f(y) = 0.2 for 0 < y ≤ 2
0.8y - 1.4 for 2 < y ≤ 3
0 elsewhere

Apologies for not knowing LaTex, here's a picture .

I believe the first thing I need to do is figure out the cumulative distribution function F(y), for this I came up with

Code:

f(y) = 0.2y for 0 < y ≤ 2
0.4y^2 - 1.4y + 1.6 for 2 < y ≤ 3
1 3 < y

Next I think I need to find the transformation functions for 0 < y ≤ 2 and 2 < y ≤ 3. So by substituting the uniform variable U in I can get $\displaystyle y = U / 0.2$ for the first segment, however for the second segment (2 < y ≤ 3) I get two quadratics here (wolfram link) so I'm not sure if this is the right track or not.

Basically my understanding of how transforming these variables works goes like this

1) Generate uniform random variable U

2) If U is less than 0.4 (which I got from subbing y=2 into 0.2y), it is transformed using $\displaystyle y = U / 0.2$. Otherwise if U is greater than 0.4 it is transformed using one of the quadratics in the above link.

Anyone able to help me out here? Much appreciated