Random tBetween Value in Pulse Train

Use this forum to post Vensim related questions.
Post Reply
cjansen
Junior Member
Posts: 12
Joined: Thu Aug 21, 2008 3:35 pm

Random tBetween Value in Pulse Train

Post by cjansen »

I have the following statement:

PULSE TRAIN (0,1,INTEGER(RANDOM UNIFORM (2,7,0)),FINAL TIME)

In short I want a pulse train where the tbetween value varies from 2 to 6. I want the pulse to fire off at a given time, say time+4 and then after that pulse fires off I want it to fire off again 6 time steps later and then again 2 time steps after that one... so forth and so on.

Upon examing the output of such a function I am observing gaps between pulses less 2 and greater then 7. In fact I've seen a gap time as high as 11.

I've tried different variations on the above code snippet but to no effect. The closet I've come to staying between the bounds of 2 and 6 was with the following:

PULSE TRAIN (0,1,INTEGER(RANDOM UNIFORM (0,1,0)*7)+1,FINAL TIME)

Which gets me to between 1 and 9.

I realize the manual mentions that using non constants in the pulse train would result in non regular behavoir but I figured it was talking about going from uniform spacing between pulses to a non uniform spacing. I didn't think it meant causing gaps between pulses that were outside of the tbetween variable.

Is this what is meant by the irregular behavoir? An is there a work around for this if that's the case?

Any help would greatly appreciated.

-Chip

PS: I'm using VENSIM DSS 5.8a (Double Precision) and I've attached the test model that I was experimenting on.
Attachments
Test.mdl
(3.56 KiB) Downloaded 231 times
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

You need to set up memory to get the effect you want and memory always means a level. To get what you want you can use something like

value = IF THEN ELSE(Time >= signal start time,1,0) ~Dmnl~|
signal start time = SAMPLE IF TRUE(time >= signal start time+duration,Time+RANDOM UNIFORM(2,6,0),-1) ~Month~|
duration = 1 ~Month~|

This assumes that INITIAL TIME >= 0 and TIME STEP < 1. The SAMPLE IF TRUE introduces the level. If you want the signal initially on, then use INITIAL TIME as the last argument to SAMPLE IF TRUE.
cjansen
Junior Member
Posts: 12
Joined: Thu Aug 21, 2008 3:35 pm

Post by cjansen »

Bob,

Thanks a bunch. This helps tremendously.

-Chip
Post Reply