function Z=xbivarn(ux, sigx, uy, sigy, rho, samples, seed) % xbivarn(ux, sigx, uy, sigy, rho, samples, seed) Bivariate normal % experiment. Generates an "unseen" normal random variable X with mean % Then from X generates a "measured" normal random variable Y, and uses a % linear estimation to determine X from Y. The output is a matrix, in % which each row represents an experimental parameter % % row description % 1 "unseen" variable x % 2 "measured" variable y % 3 x' : estimated x values from y values % 4 y' : estimated y values from x values % 5 error between x and x' % 6 error between y and y' if sigx<=0 | sigy<=0 error('sigma squared cannot be <=0') end if samples<=0 error('invalid value for samples') end G=rho*sqrt(sigy/sigx); npdf1=dfnorm(0, sigx); npdf2=dfnorm(0, sigy*(1-rho^2)); N1=rvgen(npdf1, 1, samples, seed); N2=rvgen(npdf1, 1, samples, seed^2); X=N1+ux; Y=N1.*G+N2+uy; X1=rho.*(Y-uy)./sqrt(sigy).*sqrt(sigx)+ux; Y1=(1/rho).*(X-ux)./sqrt(sigx).*sqrt(sigy)+uy; EX=(X-X1); EY=(Y-Y1); Z=[X; Y; X1; Y1; EX; EY];