How can I generate inter-arrival times from a Weibull distribution, p.d.f. $f(t)=\frac{\beta}{\alpha}\big(\frac{t}{\alpha}\big)^{\beta-1}\exp\big(-\frac{t}{\alpha}\big)^\beta$, where $\beta$ is the shape parameter and $\alpha$ is the scale parameter?


1 Answer 1


The Weibull is a powered exponential distribution. Its survival function

$$q = 1 - F(x) = e^{(-x/\alpha)^\beta}$$

therefore has a particularly tractable form: it is readily inverted to give

$$x = \alpha(-\log(q))^{1/\beta}.$$

You therefore need only generate $q$ uniformly in the interval $(0,1)$ and compute $x$. Here's an R example:

alpha <- 2
beta <- 3
n <- 1e5                                 # Sample size
x <- alpha * (-log(runif(n))) ^ (1/beta) # Sample
hist(x, freq=FALSE, breaks=50)
curve(dweibull(x, beta, alpha), add=TRUE, col="Red", lwd=2)

The work is all done on a single line labeled "Sample". The output is a histogram on which the Weibull density function is plotted. The agreement in this simulation is excellent.


(R of course offers a built-in generator rweibull. The point of this answer is to show how it might work and to provide enough details to enable a generator to be implemented in any language.)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.