% Program binorm.m % % This MATLAB Code simulates a bivariate normal distribution % with read in means and standard deviations and correlation % coefficient xm=input('mean of the x variate: ') ym=input('mean of the y variate: ') xsig=input('standard deviation of the x variate: ') ysig=input('standard deviation of the y variate: ') s=1; while s>0; rho=input('correlation coefficient between -1,1: ') x=[ ]; y=[ ]; i=0; while (i < 100), i=i+1; a=randn; x1=xm+xsig*a; y1=ym+rho*ysig*a+ysig*randn*sqrt(1-rho*rho); x=[x x1]; y=[y y1]; end; plot(x,y,'o'); s=input('Do you want to stop - if so enter 0') end