importnumpyasnpimportmatplotlib.pyplotaspltnsam=11np.random.seed(10)p=np.random.rand(nsam,1)tau=-np.log(p)time=np.cumsum(tau,axis=0)time=np.insert(time,0,0,axis=0)Y=np.arange(nsam+1)xx,yy=np.repeat(time,2)[1:-1],np.repeat(Y,2)[:-2]# Equivalent to stairs without the last elementplt.figure()plt.plot(xx,yy)plt.show(block=False)plt.figure()plt.hist(tau,bins=20)plt.show(block=False)table=np.column_stack((xx,yy))withopen("unitpoisson.dat","w")asf:np.savetxt(f,table,fmt='%f',header="time Y")