A shifted exponential density

A density is f(x)=4e^{-4(x-1)} for x\ge 1, and f(x)=0 otherwise.

  1. Find the expectation of a random variable with this density.

  2. Explain how to generate such a random variable from a single uniform draw on [0,1].

  1. If X has this density, then Y=X-1 has density 4e^{-4y} for y\ge0, which is \operatorname{Exp}(4). So \mathbb{E} X=1+1/4=1.25.

  2. The distribution function is F(x)=1-e^{-4(x-1)} for x\ge1. Solving F(x)=u gives x=1-\tfrac14\log(1-u). Draw U\sim\operatorname{U}[0,1] and return 1-\tfrac14\log U, using that 1-U is again uniform.