# How to simulate two coupled birth-death-immigration processes?

I am simulating a birth-death-immigration process for two coupled populations that interact by virtue of the birth-rate in one population being equal to the death-rate in the other population. The two coupled populations contain the 3 mechanisms births, deaths and immigrations. The birth/death rate mu is dependent on the amount in the population whereas the immigrations rate nu is independent.

The first row is births, second row is deaths and the third row is immigrations.

My thought process on how to simulate these coupled populations is by, if a death occurs, I need to decide which population the death occurs in. I do this by flipping a coin weighted by the sizes of the two populations. I then need to decide whether the death dies out completely or whether it goes into the other population as a birth. A similar thing happens if a birth occurs. I need to decide which population the birth occurs in (using weighted coin), and then determine whether the birth was due to a death in the other population or not. For immigrations I just flip a coin 50/50 to see which population it goes in, since immigrations are independent on the number in the population.

If this is correct, how would I determine if the death/birth in one population was due to a birth/death in the other population?

If my thought process is not correct, how would I got about simulating this type of process?