# Inter-arrival times of Weibull distribution

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?

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.)