question

Anggoro P avatar image
0 Likes"
Anggoro P asked Steven Hamoen answered

Value by percentage inside by case logic

Hi, I want to set a value using by case logic. However one of the case has 2 possible value and I want to set the value using some percentages.

For example if case = 1 then 30% will be 50 and 70% will be 60

I am aware that I need to code it manually, but I don't have general idea to code it. Any suggestion?

Choose One
flexscriptcode editor
· 1
5 |100000

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

Anggoro P avatar image Anggoro P commented ·
0 Likes 0 ·
Joerg Vogel avatar image
1 Like"
Joerg Vogel answered

you can use the statistical distribution dempirical( global table, stream number)

item.labels.assert("myLabelname",dempirical(Table("GlobalTable1"),1));

Returns a random sample from a discrete empirical distribution

Parameters

(str/node/num table[, num stream])

Description

A discrete empirical distribution.The table referenced must contain a list of values and probability percentages associated with each of the values. Probability percentages must be entered in column 1 starting with row 1 of the table, and their associated values are entered in column 2. The table may have as many rows as needed to define as many values as desired. The percents are entered as numbers between 0 and 100, and should add up to a total of 100 percent; otherwise any values defined after a cumulative percentage of 100 is reached will never be returned.A detailed description of the three empirical distributions used in FlexSim and their differences is included with the cempirical() command.

Example

int ptype = dempirical("prodtypes", 5);Assigns a value to the ptype variable using a discrete empirical distribution defined in a global table named "prodtypes" using random number stream 5.dempirical(current.labels["route"], 5);Returns a random variate from a discrete empirical distribution defined in a node table defined on the label named "route" of the current object, and using random number stream 5.

Command Help - FlexSim 17.2.3


5 |100000

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

Steven Hamoen avatar image
1 Like"
Steven Hamoen answered

In case there are only 2 values you can use the bernoulli() function. You can just write: bernoulli(30, 50, 60). First parameter is the chance on the second paramater. The last parameter has a chance of 100-first parameter.

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.