Okay i'm probably majorly over thinking this but i need to create a counter that counts how many weeks a certain value gets exceeded, except i honestly don't know how to do it. I thought of find the end max value and taking it away from the first max value except i can't get the last max value. here's some of my code:

i = 1
maxindividuals=0
while i < nstep:
thisTime = i * StepSize
Snew = SArray + ((Sdash(S,I,N,a)) * StepSize)
Inew = IArray + ((Idash(S,I,N,a,b,c)) * StepSize)
Rnew = RArray + ((Rdash(I,b)) * StepSize)
Dnew = DArray + ((Ddash(I,c)) * StepSize)
S = Snew
I = Inew
D = Dnew
R = Rnew
if I > maxindividuals:
maxindividuals=I
timemaxindividuals=thisTime +0.1
SArray = S
IArray = I
RArray = R
DArray = D
TimeArray = thisTime
i = i + 1

any help will be greatly greatly appreciated as i've been sitting here for a while trying to figure it out.

2
Contributors
1
2
Views
8 Years
Discussion Span
Last Post by woooee

create a counter that counts how many weeks a certain value gets exceeded

I would suggest using a function for simplicity. Return a "True" or one if the value is exceeded. This also only returns one positive. If it is possible that the value is exceeded more than once in a week, you only want to increment by one per week. Some pseudo python code

``````def exceeded( values_list, max_value ):
for value in values_list:
if value > max_value:
return 1                   ## exits function on first "found"
return 0

##---  test it
if __name__ == "__main__":
exceed_total=0
values_for_week = [ 1, 2, 3, 4, 5 ]
result = exceeded(values_for_week, 3)
exceed_total += result
result = exceeded(values_for_week, 6)
exceed_total += result
print "exceed_total =", exceed_total, " (should equal one)"``````
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.