function z = qnorm(p)
%
% z = qnorm(p)
% Find the value z s.t. Pr(Z < z) = p, where  Z ~ N(0,1).

x = 0:0.01:3.49;
cdf = gaussian_cdf(x);
if (p < 0.5)
  z = -qnorm(1-p);
elseif p > cdf(end)
  z = 3.50;
else
  u = find(cdf>=p);
  z = x(u(1));
end
