# get 10k piecewise exponential failure times
# failure rates are 1 for time 0-.5, 3 for time .5 - 1 and 10 for >1.
# intervals specifies duration of each failure rate interval
# with the final interval running to infinity
x <- rpwexp(10000, failRates=tibble::tibble(rate = c(1, 3, 10), duration = c(.5,.5,1)))
plot(sort(x),(10000:1)/10001,log="y", main="PW Exponential simulated survival curve",
xlab="Time",ylab="P{Survival}")
# exponential failure times
x <- rpwexp(10000, failRates=tibble::tibble(rate = 5, duration=1))
plot(sort(x),(10000:1)/10001,log="y", main="Exponential simulated survival curve",
xlab="Time",ylab="P{Survival}")
Run the code above in your browser using DataLab