I have been given the following task: Compute the expected value of Y=e^{-X}(X is uniform between 0 and 1) with a simulation in R. Plot the expected value as a function of the number of simulations where n is an integer between 1 and 10000 The pdf of this function is: f(y) = 1/y, for 1/e < y < 1.
The formula of finding expect value is of course: E[Y] = integrate(y * 1/y dy)
How do you simulate something likes this ? I expect you draw random sample between (1/e < y < 1) but the pdf of the distribution has different probabilities depending on what you draw it seems.
I thought about using the "sample" or "runif" functions but i can't figure out how to make those functions work with different probabilities.