## Generate random number from a two-parameter exponential distribution

Asked by Alexis Stevenson

### Alexis Stevenson (view profile)

on 21 Mar 2019
Latest activity Edited by Alexis Stevenson

### Alexis Stevenson (view profile)

on 21 Mar 2019
Accepted Answer by Torsten

### Torsten (view profile)

Hello everybody,
I am looking for a way to easily generate random numbers from a two-parameter exponential distribution. The probability density function is: . I am aware of expand() but it does not seem to include the two-parameter distribution.
Do you have any idea how I could achieve that?
Thank you very much.
Alexis

Show 1 older comment
Alexis Stevenson

### Alexis Stevenson (view profile)

on 21 Mar 2019
Sorry typo :) Thank you for noticing it.
Torsten

### Torsten (view profile)

on 21 Mar 2019
What is the support of f ?
I ask because if support(f) = IR+, f is only a probability density function if gamma = 0.
Alexis Stevenson

on 21 Mar 2019

### Torsten (view profile)

on 21 Mar 2019

gam = ...;
lambda = ...;
n = 100;
x = gam - log(1-rand(n,1))/lambda
give you 100 random numbers distributed according to your two-parameter distribution.

Alexis Stevenson

### Alexis Stevenson (view profile)

on 21 Mar 2019
Oh yes thank you so much !
I just realized the cdf was and I had to invert it.