question

Maryam H2 avatar image
0 Likes"
Maryam H2 asked Maryam H2 commented

Sampling delay times from empirical distributions by hour of the day/week

How can I read the delay time from an empirical distribution for each hour of the week? The data is organized with varying sample sizes for each hour, ranging from 0 (Sunday 12 AM) to 48 (Monday 12 AM). Each sample corresponds to a delay time, and we want to sample delay times from this empirical distribution for each hour of the week.

It's possible to separate days of the week but then is it possible/easier to read the data for each weekday by the hour from an empirical distribution, again at each hour we have an unequal number of samples and we want to sample from this distribution.

The data is in the GlobalTable1 in the model attached here.

Thanks

samplingbyhouroftheweek.fsm

FlexSim 23.2.0
flexsim healthcareby hourempricalsampling
5 |100000

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

1 Answer

·
Jeanette F avatar image
0 Likes"
Jeanette F answered Maryam H2 commented

Hello @Maryam H2,

An Empirical Distribution for an hour of a day will need to be its own table, so from your data we have created a Table for each as a Cell in a table.

1701717681496.png

The Table's first column needs to be the weight distribution and the second column is the value. We assumed an even distribution and calculated it so. Here is the Table for Hour of Week 0;

1701718029508.png

You can then reference that Cell of the Table for the Empirical Distribution for that hour.

empirical(Table("GlobalTable2").cell(Model.dateTime.hour, 2))

samplingbyhouroftheweek_1.fsm


· 10
5 |100000

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

Maryam H2 avatar image Maryam H2 commented ·

Hi @Jeanette F

Thanks for the answer, I have two questions:

1- Sometimes when I use the script to check the value samples by the code below, it returns something that is not in that hour's table. Do you know why that is?

For example, to check the value of samples for the first hour.

empirical(Table("GlobalTable2").cell(1, 2)

2- In the other script, where you created a table and cloned it to a new global table, what is the $1 does here?

..FROM GlobalTable1 WHERE [Hour of the Day] = $1"
0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Maryam H2 commented ·

1. Should be Model.dateTime.hour+1 since it's using the number of hours passed rather than the current hour the model is in.

2. That's part of a loop where the $1 is a parameter for the hour of the day, which changes for each cycle through the loop.. I'm surprised by this - I thought you were going to use hour of the week.

0 Likes 0 ·
Maryam H2 avatar image Maryam H2 Jason Lightfoot ♦ commented ·

got it, thanks!

In my model, I seperated days to have their own table, so for each week of the day I have a Global Table and that's why I used Hour of the Day column.

0 Likes 0 ·
Show more comments

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.