Reputation: 369
so I have this code:
def run_simulation(nba = 100, maxIter = 10, probI = 0.2, probR = 0.2, probI_init = 0.1, network = nx.erdos_renyi_graph, netParam=0.1, rep=10):
r = 0
while r < rep:
init(nba, probI)
i = 0
while i < maxIter:
step(probR, probI)
nbI = collect_statistics()
if nbI == 0:
break
i = i + 1
print(statS[-1])
r = r +1
run_simulation()
this code yields 10 numbers like this:
My question is: is there a way to compute the average of those 10 numbers and how?
Thanks a lot in advance!
Upvotes: 0
Views: 184
Reputation: 54743
Since statS
is clearly a global list being created and modified outside of this routine, it's a little hard to tell, but the OBVIOUS answer is to print(sum(statS)/len(statS))
after the loop exits.
Upvotes: 1