.h>#include<stdlib.h>intmain(){?intN=0,T=10;?doubleU,E;?doublet=0;?doublelamda=1.0;?printf("时间t%d:%lf,发生的次数N:%d\n",N,t,N);?srand((unsigned)time(NULL));//初始化随机数?while(1)?{ U=rand()/(RAND_MAX+1.0); E=-(1/lamda)*log(U); t=t+E; if(t>T) break; else { N=N+1; printf("时间t%d:%lf,发生的次数N:%d\n",N,t,N); }?}?return0;}MATLAB代码%样本函数1lamda1=1.0;T1=15;t1=0;N1=0;x1=[];y1=[];x1(1)=0;y1(1)=0;whilet1<T1;U1=rand();E1=-(1/lamda1)*log(U1);t1=t1+E1;if(t1<T1)N1=N1+1;x1(N1+1)=t1;y1(N1+1)=N1;endendy1x1%样本函数2lamda2=2.0;T2=15;t2=0;N2=0;x2=[];y2=[];x2(1)=0;y2(1)=0;whilet2<T2;U2=rand();E2=-(1/lamda2)*log(U2);t2=t2+E2;if(t2<T2)N2=N2+1;x2(N2+1)=t2;y2(N2+1)=N2;endendy2x2stairs(x1,y1,'r-');holdonstairs(x2,y2,'k-');title('泊松过程')xlabel('时间t')ylabel('计数过程N(t)')legend('样本函数1','样本函数2',2)title('泊松过程')xlabel('时间t')ylabel('计数过程N(t)')