rpwexp {hesim} | R Documentation |
Random generation for piecewise exponential distribution
Description
Draw random samples from an exponential distribution with piecewise rates.
rpwexp
is vectorized and written in C++ for speed.
Usage
rpwexp(n, rate = 1, time = 0)
Arguments
n |
Number of random observations to draw. |
rate |
A matrix of rates where rows correspond to observations and columns correspond to rates during specified time intervals. |
time |
A vector equal to the number of columns in |
Value
A vector of random samples from the piecewise exponential distribution. The length of the sample is determined by n. The numerical arguments other than n are recycled so that the number of samples is equal to n.
Examples
rate <- c(.6, 1.2, 1.3)
n <- 100000
ratemat <- matrix(rep(rate, n/2), nrow = n,
ncol = 3, byrow = TRUE)
t <- c(0, 10, 15)
ptm <- proc.time()
samp <- rpwexp(n, ratemat, t)
proc.time() - ptm
summary(samp)
[Package hesim version 0.5.4 Index]