Cancel
Showing results for
Did you mean:

# random value from table

Creator

Hi all,

I have a simple problem, which I cannot solve.

I have four variables in a method and need to assign each variable a value between 0 and 9.

The Sum off all four variables need to be equal to 9.

I then save the results in a table and repeat it for 100 times (How to save the values in the tables is no problem) It is important that all numbers from 0 to 9 are eqaully distributed for EACH variable. This is the crux. Can anybody help me?

Im very pleased for any solution.

Thank you very much.

Regards, Ben

5 REPLIES

# Re: random value from table

Siemens Phenom

Hello Benedikt,

use z_uniform(1, 0.0, 1.0) to generate 4 real random numbers between 0.0 and 1.0. Calculate the value f by dividing 9.0 through the sum of your 4 random numbers. Then multiply each number by the value f.

Regards,

Ralf
------------------------------------------------------------------------------------------------------
Did you like the answer? Then click the Thumbs Up button.

# Re: random value from table

Siemens Phenom

Just one additional remark: You won't get an equal distribution for each variable between 0 and 9. Since the constraint that the sum has to be 9 favours smaller numbers.

Regards,

Ralf
------------------------------------------------------------------------------------------------------
Did you like the answer? Then click the Thumbs Up button.

# Re: random value from table

Creator

Thanks. That idea works.

Unfortunately I really need the equal distribution

I am working on a different solution right now but struggeling at the following:

Is there a way to chose randomly between four (self determined) parameters that I have saved in a table {1,1}..{4,1} and adress them in a method?

Regards,

Ben

# Re: random value from table

Gears Esteemed Contributor
try z_dEmp
 Steffen Bangsowfreelance simulation specialist  web: www.bangsow.eumail: steffen@bangsow.net

# Re: random value from table

Creator

Thanks.

I found, what I needed.

Regards,

Ben