how to determine the number of positive values every 5 time-steps

Use this forum to discuss any issues relating to Systems Dynamics and Systems Thinking.
Post Reply
Ryan
Junior Member
Posts: 6
Joined: Wed Jun 19, 2019 11:41 am
Vensim version: PLE

how to determine the number of positive values every 5 time-steps

Post by Ryan »

Hello Everyone
my model consists of a random number generator. it generates positive and negative numbers.
is there a way to find out the number of positive values generated every 5 time-steps?
in other words, I want to specify a variable in my model called "number of positive values" to show me the number of positive values every 5 time steps.

here is an example of what I want to do:
imagine my model has generated the following numbers in 10 consecutive time steps.
-1.02582, -0.780324, 0.168143, 0.287632, 0.569913, -0.981128, 0.544378, 0.472801, -0.370337, -0.387548

"number of positive values" must get the following values:
in the fifth time step : 3
in the sixth time step : 3
in the seventh time step : 4
in the eighth time step : 4
in the ninth time step : 3
in the tenth time step : 2

thanks in advance.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: how to determine the number of positive values every 5 time-steps

Post by Administrator »

Try something like

random number positive flag = if then else ( RN > 0 , 1 , 0 )
Number of positive values = integ( random number positive flag / time step - reset count , 0 )
reset count = if then else ( number of time steps elapsed = 5 , Number of positive values / time step , 0 )
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Ryan
Junior Member
Posts: 6
Joined: Wed Jun 19, 2019 11:41 am
Vensim version: PLE

Re: how to determine the number of positive values every 5 time-steps

Post by Ryan »

thank you so much.
apparently, "number of time steps elapsed" is not a built-in Vensim function.
I tried:
number of time steps = Time/TIME STEP
reset count = if then else ( number of time steps/5=0 , Number of positive values / time step , 0 )

but for an unknown reason, it doesn't seem to be working.
I appreciate any help.
thanks
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: how to determine the number of positive values every 5 time-steps

Post by Administrator »

No it's not a built in function, but it's quite easy to figure out how to do it.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Post Reply