question

Allen Greenwood avatar image
0 Likes"
Allen Greenwood asked Michael D11 published

Value in an Empirical distribution

How to get the value of a particular row and column in an Empirical distribution table? Seems like it should be able to be referenced like a global table but that doesn't seem to work.

FlexSim 21.2.2
flexsim 21.2.2empirical distribution
· 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.

Jeanette F avatar image Jeanette F ♦♦ commented ·

Hi @Allen Greenwood, was one of Ryan Clark's or Felix Möhlmann's answers helpful? If so, please click the "Accept" button at the bottom of the one that best answers your question. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·
Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered Michael D11 published

The data of an empirical distribution is saved in a treenode containing bundle data in the tree of the respective "empirical distribution" object.

Values in it can be accessed with the "getbundlevalue" command.

// Get reference to the node containing the data - 
// replace "EmpiricalDistribution1" with the name of the distribution
treenode bundle = Model.find("/Tools/EmpiricalDistributions/EmpiricalDistribution1>variables/data");

// Assign value to variable
double val = getbundlevalue(bundle, <row>, <column>);

Important note: The rows ("entry") and columns ("field") of bundles are 0-indexed.

1631103050675.png


1631103050675.png (22.4 KiB)
· 4
5 |100000

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

Allen Greenwood avatar image Allen Greenwood ♦ commented ·
Thanks Felix. I didn't realize it was saved as a bundle. In code, I need to know how many rows are in the data. In my case, I am specifying an empirical distribution using pairs of values and corresponding percents. Whereas the new Empirical Distribution is more for a set of raw data. It seems that the older approach of using a global table and dempirical (or cempirical) distribution is better for what I need.
0 Likes 0 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ Allen Greenwood ♦ commented ·
If you are using pairs of values and corresponding percents, use the "weighted" option and put your percents as the weights. Then I think you'll have what you are looking for.
1 Like 1 ·
Allen Greenwood avatar image Allen Greenwood ♦ Jordan Johnson ♦♦ commented ·
I did that initially. However, in some code in the model, I need to know how many rows are in the distribution table. That's were I got stuck since I couldn't just use a table method.
0 Likes 0 ·
Show more comments
Ryan Clark avatar image
0 Likes"
Ryan Clark answered Joerg Vogel commented

Hello @Allen Greenwood,

That's not quite how Empirical Distributions work. They work like using any other statistical distribution: you define the parameters of the distribution and FlexSim outputs a random value that fits the distribution every time the distribution is accessed. The Empirical Distribution works the same way, except you manually define the parameters.

Does that answer your question?

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.