# -*- coding: utf-8 -*- """ Created on Wed Feb 04 12:13:53 2015 Listing 15.2 : décroissance d'une population de noyaux radioactifs @author: grivet """ import numpy as np import matplotlib.pyplot as plt N = 1000; P = 0.1 NR = 40; nB = np.zeros(NR) tab = np.zeros(N) nB[0] = sum(tab) for ir in range(1,NR): for i in range(N): x = np.random.rand() if x <= P and tab[i] == 0: tab[i] = 1 nB[ir] = sum(tab) nA = N-nB t = np.array(range(NR)) plt.xlabel("nombre de balayages") plt.ylabel("populations") plt.plot(t,nA,'ob',t,nB,'or') plt.plot(t,N*exp(-P*t),'-k')