Untitled
unknown
plain_text
4 years ago
825 B
9
Indexable
iterations = 100
T_final = 1
j_cells_final = []
for i in range(iterations):
j = 1
j_cells = []
#j_cells.append(j)
t = 0
times = []
times.append(t)
while t < T_final:
t += np.random.exponential(1/j)
times.append(t)
j_cells.append(j)
j +=1
j_cells_final.append(j_cells[-1])
print(j_cells_final)
def num_occ(L, n):
count = 0
for i in range(len(L)):
if L[i] == n:
count +=1
return count
X = np.amax(j_cells_final)
prob_list = []
for i in range(1,X+1):
num_occs = num_occ(j_cells_final, i)
p = num_occs / iterations
prob_list.append(p)
#print(i)
print(X)
print(prob_list)
js = np.linspace(1,X+1,X,endpoint=False)
print(js)
fig, ax = plt.subplots(1, 1, figsize=(9, 6))
plt.plot(js,prob_list)
plt.show()Editor is loading...