Bug? With The Random Uniform Function

Use this forum to post Vensim related questions.
Post Reply
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Bug? With The Random Uniform Function

Post by nikvyas »

Good morning all.

I've built a complex model and recently did sensitivity analysis on it. However, the results weren't entirely as expected. On further investigation, I found the following:

random=RANDOM UNIFORM( 0 , 1 , overall seed )

PI177=IF THEN ELSE( RANDOM UNIFORM( 0 , 100 , overall seed ) <="% Of Spares Sourced Within 1 hour","Fault Found @ Depth" ,0)

% Of Spares Sourced Within 1 hour=95

PRS=IF THEN ELSE( RANDOM UNIFORM( 0 , 1 , overall seed ) <=Immediate Query Rate,("Number Of A/C needing Repair and Replace"+"Real A/C Downtime Due To Direct Repair") , 0)

Immediate Query Rate=0.06

seed = 5555

I have found that if I alter "% Of Spares Sourced Within 1 hour" to 90, "random" also changes!

With "% Of Spares Sourced Within 1 hour" set to 95, the first 5 time steps of "random" looks like:

0.6019, 0.9343, 0.7949, 0.2344, 0.5990

With "% Of Spares Sourced Within 1 hour" set to 90, the first 5 time steps of "random" looks like:

0.6019, 0.6861, 0.1793, 0.9624, 0.1119

However, if I alter "Immediate Query Rate", the random number remains unchanged. In fact, I've altered a lot of the other variables within the model and none of them changes "random".

Note, the model has many more variables, but I've given a sample here.

So the question is - why does "random" change, even though the seed is constant? Why does altering a variable, that is completely unconnected, change "random"? Why does altering other variables, not alter "random".

The only difference I can see between "PI177" and "PRS", is that the random uniform number is between 0 and 1 in "PRS" and 0 to 100 in "PI177"

Any help appreciated.

[Edited on 2-6-2007 by nikvyas]
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

In general it is best not to embed a RANDOM function in an IF THEN ELSE statement because IF THEN ELSE will only evaluate the branch required - ef

IF THEN ELSE(RANDOM UNIFORM(0,1,0) > threshold,RANDOM UNIFORM(0,100,0),36)

changing threshold will change everything on noise stream 0. Note that your equation should not cause this, but you may have oversimplified them.

If you do want to use RANDOM.. in an IF THEN ELSE I would recommend you confine it to its own noise stream so that it does not alter the other noise sequences.

In general it is best to use noise stream 0 and set the model constant NOISE SEED and not to assign a global noise seed to define the noise stream used globally.
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Post by nikvyas »

Thanks Bob - however that doesn't seem to be the problem. I have now amended my model, so that all of the seeds are now seperate (i.e., there is no global seed) - and still, if I alter a variable elsewhere in the model, the random numbers also change!

I can't post the model on this forum, but is there an email address I can send the model to for some advise?

Thanks

Nik
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

Hi Nik,

You can email me the model to bob@vensim.com and I will take a look - but I am guessing you overlooked a RANDOM... somplace.
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Post by nikvyas »

Thanks Bob - I've emailed the model.

The password is:

ziggyzag

[Edited on 2-8-2007 by nikvyas]
Post Reply