close all; clear; n=500; r1s=[]; r2s=[]; xs=[]; ts=1:n; for t=1:n r1=rand(); r2=rand(); x = sqrt(-2*log(r1))*sin(2*pi*r2); r1s(end+1)=r1; r2s(end+1)=r2; xs(end+1)=x; end subplot(211) plot(ts,r1s); hold on; plot(ts,r2s); plot(ts,xs); legend('r1','r2','x'); subplot(212); hist(xs);