Solutions for Jupyter notebook on functions


Question 1

d= np.random.poisson(5, 12)
def findratio(d):
  return np.var(d)/np.mean(d)
print(findratio(d))

and

res= []
for i in range(10):
  d= np.random.poisson(5, 12)
  res.append(findratio(d))
print(np.mean(res))

or using a list comprehension

print(np.mean([findratio(np.random.poisson(5, 12)) for i in range(10)]))