Periodic Random Numbers

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

Periodic Random Numbers

Post 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.
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post 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).
nikvyas
Senior Member
Posts: 112
Joined: Mon Apr 24, 2006 3:17 pm

Post by nikvyas »

That's great - thanks Bob.
Post Reply