Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Navigation
- Tecnomatix
- Forums
- Blogs
- Knowledge Bases
- Groups

- Siemens PLM Community
- Tecnomatix
- Plant Simulation
- random value from table

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-07-2016 04:44 PM

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

Solved! Go to Solution.

5 REPLIES

Re: random value from table

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-08-2016 02:14 AM

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.

Did the answer solve your problem? Then accept the answer as solution.

Ralf

------------------------------------------------------------------------------------------------------

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

Did the answer solve your problem? Then accept the answer as solution.

Re: random value from table

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-08-2016 02:17 AM

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.

Did the answer solve your problem? Then accept the answer as solution.

Ralf

------------------------------------------------------------------------------------------------------

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

Did the answer solve your problem? Then accept the answer as solution.

Re: random value from table

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-08-2016 03:28 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-08-2016 03:30 AM

Steffen Bangsowfreelance simulation specialist web: www.bangsow.eu mail: steffen@bangsow.net |

Re: random value from table

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-11-2016 06:17 AM

Thanks.

I found, what I needed.

Regards,

Ben

Follow Siemens PLM Software

© 2019 Siemens Product Lifecycle Management Software Inc