Drawing values associated with exponential clock Suppose I have a jump Markov process $(N_z)_{z\in[0,L]}$ where $L = 10$ say, with state space $\mathbb{N}$ and infinitesimal generator $\mathcal{L}.$
When it reaches state $n > 0,$ a random clock with exponential distribution and parameter $2n^2/5$ starts running. When the clock strikes the process jumps to $n+1$ or $n-1$ with probability $1/2,$ and $0$ is set to be an absorbing state.
I am trying to understand how to create a numerical simulation of this and understand the jumps associated with it.
If I want to generate data with jumps associated with this exponential clock, what does that mean? Can I simply draw a vector a values from an exponential distribution with parameter 2n^2/5? Does the parameter change with every state?
 A: Presumably $2n^2/5$ is the rate.  I am not clear what $L$ or $\mathcal L$ are.
So I would have thought yes, you generate times for each jump using these rates (which change as $n$ changes), decide whether you add or subtract $1$ from $n$ and repeat, stopping if $n=0$ as this is an absorbing state or the next jump is due to take infinite time. You then cumulate these times to give the time at which you arrive at each $n$.
You need a starting $n$ for your simulation, presumably at time $0$.
There is an interesting point here: jumps tend to happen faster when $n$ is large.  So while this looks like a random walk, where the number of jumps is almost surely finite before hitting $0$ but the expected number of jumps before hitting $0$ is infinite, I suspect that here the expected time before hitting $0$ may be finite.
Here is an example of a possible simulation in R:
set.seed(2021)
startn <- 10

j <- 1
maxj <- 10^5
n <- startn
time <- 0


while (n[j] > 0 & j < maxj){
   time[j+1] <- time[j] + rexp(1, rate=2*n[j]^2/5)  
   n[j+1] <- n[j] + sample(c(-1,1),1)
   j <- j+1
   }

plot(time, n, xlim=c(0,max(time)), ylim=c(0,max(n)))


That involved $434$ jumps and a total time of about $17.2$.
The pattern will vary with where you start from and what seed you use in the simulation as runs can finish quickly or slowly.  I put maxj into the code to handle extreme cases: for example

*

*with startn <- 10 and set.seed(2) I think you may need just over $156$ million simulated jumps (a long simulation and more jumps than can reasonably be used for plotting), though the time to hit $0$ seems to be a more reasonable $84.75$


*with startn <- 10 and set.seed(1) I think you only need $44$ simulated jumps, and the time to hit $0$ seems to be about $16.3$.
