I am simulating a system where I have as a function of time the rate at which something happens, like for instance n atoms per second passes a boundary. Now what happens in the system is that as soon as one atom passes the boundary, everything goes back to initial values. So my problem is that I don't have a very good idea on how to simulate the stochastic nature of the system given that the function I have is not probability for crossing as a function of t but rather a rate. Does anyone have an idea on what to do? Edit: So basically I want to know that given this rate function, when should I expect the first atom to cross the boundary on average.