% QSAMPLE file qsample.m Simulates sample for given population density % Version of 1/31/96 % Determines sample parameters % and approximate population parameters. % Assumes dfsetup or acsetup has been run X = input('Enter row matrix of VALUES '); PX = input('Enter row matrix of PROBABILITIES '); n = input('Sample size n = '); m = length(X); U = rand(1,n); T = dquant(X,PX,U); ex = sum(T)/n; EX = dot(X,PX); vx = sum(T.^2)/n - ex^2; VX = dot(X.^2,PX) - EX^2; disp('The sample is in column vector T') disp(['Sample average ex = ', num2str(ex),]) disp(['Approximate population mean E(X) = ',num2str(EX),]) disp(['Sample variance vx = ',num2str(vx),]) disp(['Approximate population variance V(X) = ',num2str(VX),])