I have a fairly big loop that needs to run 500 times, and I'm new to using the programming language and doing this type of simulation.
But I need to document the results of each run, and if the list (table1) contains either all 0's, all 1's or a mix of both.
I was just wondering what method would be the fastest to find out what proportion of the 500 simulations, resulted in a list that contained all 0's, all 1's or a mix and if append would slow it down too much.
for x in range(0, 500):
times = 300
gamma_val = 2
table1 = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
total = 0.0
while total < times:
table = [0 for i in range (21)]
for d1 in range(21):
if table1[d1]:
table[d1] = -(1/gamma_val)*math.log((random.random()))
else:
table[d1] = -(math.log(random.random()))
####Goes on to make new table1 with changes, either all 1's, all 0's or a mix of 0s #########and 1s
files1 = 0
files01 = 0
files0 = 0
if "1" "0" in table1 == True:
files01 += 1
elif 1 in table == True:
files1 += 1
elif 0 in table1 == true:
files0 += 1