Page 1 of 1

accessing random numbers, in sequence.

Posted: Fri Nov 10, 2006 12:13 pm
by Gem
Hello.

I was wondering if somebody could help me with a little problem. I have set up a variable number process (called 'variable 1'). I then have another process (called 'cummulative') which is the cummulative of a non-linear graph (therefore 'cumulative' is also non linear). What I want to do, is sample the 'cumulative' graph every 'variable 1' step. For instance, if 'variable 1' was 2,4,1,2,6,8,5,7,6,9,1,3,7,3,6 etc and 'cumulative 1' was 23,25,27,29,32,32,33,31,39,45 etc, then the 'sample' would look like:
0 1 0 1 1 0 0 1 etc.

Hope this is clear.

Thanks a lot for your help.

Gem

Posted: Fri Nov 10, 2006 2:07 pm
by bob@vensim.com
I can't understand what you want.

Posted: Fri Nov 10, 2006 2:16 pm
by Gem
Hello Bob - sorry I didn't make my problem clearer.

I have a non linear cummulative graph. The time period is 0-100 hours. After 100 hours, the graph reaches 75 on the Y axis (number of widgets).

Now, what I want to do is randomly sample that graph. So, say for instance the random generator gives me the values 1, 6, 4, 10, 11 - then what I need to do is have a spike when random widgets (the y axis on the cummulative graph) reaches 1, 7, 11, 21, 32.

Hope this is a little more clearer Bob.

Thankyou for the taking the time to help.

Gem

Posted: Sat Nov 11, 2006 12:04 pm
by bob@vensim.com
You can use:


spike = new target - old target
old target = INTEG(spike/TIME STEP,init old target)
new target = MAX(old target,cummulative lookup(random variable))

You may need to go for something more complicated depending on the disrete/continuous conceptualization of your model.

Posted: Mon Nov 13, 2006 8:44 am
by Gem
Thanks again Bob.

However....................when I run the model I get an error as follows:

old target: simultaneous initial value equations involving: old target

Posted: Tue Nov 14, 2006 1:33 pm
by bob@vensim.com
You need to set "init old target" to a constant - or perhaps you just missed the "init" in front of that.