function mcm4eurocall
% Monte Carlo Pricing for a European Call Option (2009), 
% Adapted from D.J. Higham, Comp.Sci.&Engr., Nov/Dec 2004, pp.72-79.
clc; clear
%
fprintf('Monte Carlo Pricing for a European Call Option (2009)');
A0 = 2; K = 1; r = 0.05; sigma = 0.25; T = 3; N = 1.e6; PC = 95/100;
randn('state',50);
A = A0*exp((r-0.5*sigma^2)*T+sigma*sqrt(T)*randn(N,1)); % Asset Price
C = exp(-r*T)*max(A-K,0); % Call Prices with Acceptance by Max;
Cmean = mean(C);
SE_C = std(C)/sqrt(N);
width = norminv((1+PC)/2)*SE_C; % 100*PC% CI Bandwidth
CImin = Cmean-width; % Confidence Inteval left
CImax = Cmean+width; % Confidence Inteval right
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fprintf('\nCImin=%6.4f < Cmean=%6.4f < CImax=%6.4f;\n',CImin,Cmean,CImax); 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function  z = norminv(p)
z = -sqrt(2)*erfcinv(2*p);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% end mcm3eurocall.m