Page 1 of 1

Periodic Random Numbers

Posted: Wed May 03, 2006 8:16 am
by nikvyas
Hello all.

I have a question that might very well be simple to answer (I'm fairly new to Vensim, so am learning as I go along). From what I understand of the Random functions, they give a random number every time interval (in my model this is set to 1 hour). However, what I want is to have a pulse of 1 every X hours (where X is a random number between 5 and 7 say). Could somebody please tell me how I do this?

Thanks.

Posted: Wed May 03, 2006 10:05 am
by bob@vensim.com
The following will do this (and work in any Vensim):

output = IF THEN ELSE(Time > next time,pulse size,0)
next time = INTEG(IF THEN ELSE(Time > next time,
INTEGER(RANDOM UNIFORM(4,7.99999,0)),0)/TIME STEP,
6)

you could also other random distributions and SAMPLE IF TRUE for next time (actually there are lots of ways to do the same thing).

Posted: Wed May 03, 2006 10:33 am
by nikvyas
That's great - thanks Bob.