[R] queue simulation

Bernardo Rangel Tura tura at centroin.com.br
Mon Mar 22 10:38:07 CET 2010


On Mon, 2010-03-22 at 02:49 -0600, Carlos Ernesto Lopez Nataren wrote:
> Hello everybody :) I am trying to simulate a queue with times of arrival to the queue and time taken to dispatch every member of the queue coming from two exponential distributions, I am interested in knowing the number of people at any time and the time that takes every member of this queue to be dispatched.
> 
> I thought this was gonna be an easy task but I've failed to try to simulate this, is there any package that does this already?
> 
> Any help will be greatly appreciated.
> 
> Thank you very much
> Carlos

Carlos, if I understand your problem do you need know the time for each
person in a queue dispatched.

You say this time  fit a exponential distribution, so do you have a rate
of dispatch (x dispatch per time)  

If I want generate 10 times of dispatch rate 0.4, use the command 

times <- rexp(10,0.4)

If I need the total delay for each person,  use the command

cumsum(times)

If I need the average time in the queue, use the command

means(cumsum(times)) 


-- 
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil



More information about the R-help mailing list