0

I have a rather simple question.

I have system with different states, departure rate = mu and arrival rate = lambda.

If i want to calculate the time to leave a state i want to do the following:

time_to_transition <- ....

Obviously i need help with the "..." part. What i want the code to say is that time_to_transition = Exp(mu) + Exp(lambda).

When i try:

time_to_transition <- Exp(mu) + Exp(lambda)

I get the error message "Exp" not found. Can any1 help me write it correctly

/Peter

PeterNiklas
  • 75
  • 1
  • 9

1 Answers1

2

When you have two processes with exponential inter-event times having rates μ and λ, the next event will occur at the minimum of the two times. By the superposition property of exponentials, the min can be modeled as having an exponential distribution with a rate of μ+λ. The outcome is then selected to be the μ process with probability μ / (μ + λ), or the λ process otherwise [with probability 1 - (μ / (μ + λ)) = λ / (μ + λ).]

To generate exponentials in R, use the rexp function as documented here.

pjs
  • 18,696
  • 4
  • 27
  • 56