% Description: compute the cumulative normal distribution function. 
%This polynomial approximation method gives six decimal place accuracy
function y=cndf(d1);
if (d1>=0)
flag = 0;
z = d1;
else
flag = 1;
z = -d1;
end
k= 1/(1+0.2316419*z);
a = [0
0.31938153
-0.356563782
1.781477937
-1.821255978
1.330274429];
% Horner's scheme
p = a(6);
for i = 5:-1:1
p = p*k+a(i);
end

y = 1 - exp(-z^2/2)*p/sqrt(2*pi);
if (flag)
y = 1 - y;
end