In [2]:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt; plt.rcdefaults()
import matplotlib.pyplot as plt
In [12]:
'''
Goal is to get 100,000 trials, and store for each of them the time since the last CP
'''
T = 6 # seconds
h = 2 # Hz
samples = []
for n in range(100000):
time = 0
while time < T:
dwell_time = np.random.exponential(1. / h)
last_cp_time = time
time += dwell_time
samples += [T - last_cp_time]
plt.figure()
plt.hist(samples, bins=100, normed=True)
plt.show()
In [1]:
n = 0
while n < 10:
n += 1
if n % 2 == 0:
continue
print(n)
In [3]:
d = {'yes': 2, 'no': 33, '3': 99}
print(d[str(3)])