Generating data from a specific distribution

Let X1,...,Xn be a random sample from the pdf

f(x)=(1/b)exp[-(x-a)/b], a< x< infinity, 0< b< infinity,

where a and b are location and scale parameter, respectively.

Now I have to generate X of 1000 observations from the pdf. I am a R user.

For initiate the problem, I set parameter values of a and b arbitrarily. But to generate the probability f(x), I need to set the values of x, but I have been asked to generate X from the pdf. It seems to calculate the probabilities f(x) and to generate the values of X are simultaneous work. How can I do that ?

• (Trying not to give a complete solution to a homework problem:) The usual method to take a first stab at generating random variables (if prevented from using a built-in function) from a particular distribution is to invert the function to get a quantile function and then feed it random variates from the uniform distribution on the interval [0,1]. You can look at the shape of the distribution thereby produced using hist. hist( -log( runif(1000) ) ). I'm guessing this is homework from a mathematical statistics course and that you should demonstrate steps in getting to your final solution. – DWin Nov 30 '15 at 2:19
• Close vote on the hypothesis that this is request of stats advice. – DWin Nov 30 '15 at 2:24
• @42- hm, that's inversion method. – user 31466 Nov 30 '15 at 2:44
• Yes, it is. What is your point? – DWin Nov 30 '15 at 2:45

Use rexp function to generate vector with rate equal to 1/b and then shift the result by adding a.