function t = dquant(X,PX,U) % DQUANT t = dquant(X,PX,U) Quantile function for a simple random variable % Version of 10/14/95 % U is a vector of probabilities m = length(X); n = length(U); F = [0 cumsum(PX)+1e-12]; F(m+1) = 1; % Makes maximum value exactly one if U(n) >= 1 % Prevents improper values of probability U U(n) = 1; end if U(1) <= 0 U(1) = 1e-9; end f = rowcopy(F,n); % n rows of F u = colcopy(U,m); % m columns of U t = X*((f(:,1:m) < u)&(u <= f(:,2:m+1)))';