This is a copy of the same function from rpexp from package
msm.
Copied here to reduce dependencies.
rpexp(n = 1, rate = 1, t = 0)number of observations. If length(n) > 1, the length is
taken to be the number required.
vector of rates.
vector of the same length as rate, giving the times at
which the rate changes. The first element of t should be 0,
and t should be in increasing order.