- #1
maka89
- 68
- 4
Hello guys!
I am learning a bit on queue theory in one of my courses, and decided to try and do some simulations even though it is not mandatory. (Curriculum only covers the steady state, where it can be treated mathematically with ease).
Im looking at a birth-death process, where the time til next birth and next death are both exponentially distributed.
My algorithm:
---------------------------------------------------------------------------------------------------------------------------------------------
Intitialization: Set state to [itex]n=0[/itex](Number of people in queue and getting service) , set current time [itex]t=0[/itex], choose end simulation time [itex]t_{max}[/itex]
Loop until the time [itex]t[/itex] has reached [itex]t_{max}[/itex]:
- Get two random numbers from exponential distributions. One representing time until next death. One until next birth. The two numbers have different rate parameters.
- Choose the lowest of these two numbers as [itex]\Delta t[/itex].
- Set the state to [itex]n+1[/itex] or [itex]n-1[/itex], depending on which of the numbers were chosen.
- Update the time [itex]t \rightarrow t +\Delta t[/itex].
- Save the state and time period.
End loop.
----------------------------------------------------------------------------------------------------------------------------------------------
This process is repeated many times, and used to create probability densities for each of the states.
My question:
My algorithm simply discards the higher of the two randomly generated numbers. The state is then updated and two new random numbers are generated. Is this correct, or should the value of the second number be taken into account somehow after changing to the next state? The rate parameters of the probability distributions are not generally the same at each state.
I am learning a bit on queue theory in one of my courses, and decided to try and do some simulations even though it is not mandatory. (Curriculum only covers the steady state, where it can be treated mathematically with ease).
Im looking at a birth-death process, where the time til next birth and next death are both exponentially distributed.
My algorithm:
---------------------------------------------------------------------------------------------------------------------------------------------
Intitialization: Set state to [itex]n=0[/itex](Number of people in queue and getting service) , set current time [itex]t=0[/itex], choose end simulation time [itex]t_{max}[/itex]
Loop until the time [itex]t[/itex] has reached [itex]t_{max}[/itex]:
- Get two random numbers from exponential distributions. One representing time until next death. One until next birth. The two numbers have different rate parameters.
- Choose the lowest of these two numbers as [itex]\Delta t[/itex].
- Set the state to [itex]n+1[/itex] or [itex]n-1[/itex], depending on which of the numbers were chosen.
- Update the time [itex]t \rightarrow t +\Delta t[/itex].
- Save the state and time period.
End loop.
----------------------------------------------------------------------------------------------------------------------------------------------
This process is repeated many times, and used to create probability densities for each of the states.
My question:
My algorithm simply discards the higher of the two randomly generated numbers. The state is then updated and two new random numbers are generated. Is this correct, or should the value of the second number be taken into account somehow after changing to the next state? The rate parameters of the probability distributions are not generally the same at each state.