question

Jim Montgomery avatar image
0 Likes"
Jim Montgomery asked Jim Montgomery answered

Problem with Poisson Distribution governing arrivals but producing outlyers

I was using the custom arrivals table to simulate patient arrivals to an emergency room (see Fig 1). The problem is that, as poisson is an unbounded distribution, on occasion, this generates an artificially high returned quantity of patients for the hour. For example, in my empirical data set, the number of patients arriving in an hour never exceeds 25. In the model’s poisson-generated data, the number of arrivalls per hour reaches as high as 46. This appears to be causing problems as I attempt to validate the model.

Fig 1

How can I keep the variation in arrivals the poisson distribution gives be, while at the same time, cap the max arrivals to 25 per hour? I attempted to achieve this by adding the the “min” equation to the table (See Fig 2). The modification had no impact on the arrivals. What would be the solution?

Fig 2

Thanks,

Jim

@tee.hiett

FlexSim HC 5.1.0
arrivalspoisson distributioned arrivals
limrz.png (122.5 KiB)
tioye.png (138.9 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Matthew Gillespie avatar image
1 Like"
Matthew Gillespie answered Matthew Gillespie commented

I'm not sure why you say the min function had no impact. It seems to be working fine:

cappoisson.fsm

Statistically, though, this might not be the best solution as it will cause a spike at 25 (since you're taking all the area under the curve from 25 to the right and piling it up at 25). You would probably want to re-sample the distribution rather than just cap the value. You could write a user command with code like the following and put the user command in the Number of Arrivals.

int mean = parval(1);
int cap = 25;

int val = cap + 1;
while(val > cap)
	val = poisson(mean, 1);

return val;

cappoisson.fsm (62.3 KiB)
· 5
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jim Montgomery avatar image Jim Montgomery commented ·

Thanks, Matthew, for helping me find my error. Also, I appreciate the introduction to

"script console" and "output console" which I had not used before. ...one question. how did you get script and output consoles to show up in a split screen? ....next question, where in the arrivals table, would the script above go? Thanks, Jim

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Jim Montgomery commented ·

I just grabbed the Output Console tab and dragged it to undock the window. I then docked it to the right of the script console by hovering over the right side of the plus that appears and then releasing my mouse button.

Put this code in a user command (Toolbox > Add > Modeling Logic > User Command). Put that code in the code field and set the name and parameters to what you want then put that user command in the arrivals table.

0 Likes 0 ·
Tee Hiett avatar image Tee Hiett commented ·

Jim,

You might consider using a "while" statement as shown in attached.

Teecappoisson-2.fsm

0 Likes 0 ·
cappoisson-2.fsm (62.2 KiB)
Jim Montgomery avatar image Jim Montgomery commented ·

Tee, I like that. If the arrival value is > 25 then a new value is selected randomly from the poisson distribution. But can all that code go into the small "Number of Arrivals" block in the Arrivals Table?

0 Likes 0 ·
Tee Hiett avatar image Tee Hiett commented ·
cappoisson-3.fsm

Jim, Here is one way you can create and use user commands.  
Let me know what you think.
See you Friday.
Tee

0 Likes 0 ·
cappoisson-3.fsm (82.9 KiB)
Jim Montgomery avatar image
0 Likes"
Jim Montgomery answered

Very cool! Thank you Matthew and Tee for introducing me to User Commands.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.