function [Price,ConInterval] = aapapricemc (CurrentPrice,StrikePrice,...
    IntRate,TimeToMaturity,StdDeviation,CallOrPut,NumOfSteps,NumOfPaths)
% AAPAPRICEMC  pricing arithmetic average price of Asian option with
% Monte-Carlo Simulation 
% PARAMETERS:
% Price is the option price calculated with Monte-Carlo Simulation
% ConInterval is the 95% confidence interval for the estimation of the price
% CurrentPrice is the current price of the underlying asset
% StrikePrice is the strike price of the option
% IntRate is the risk-free interest rate
% TimeToMaturity is the time to maturity
% StdDeviation is the standard deviation of the return on the price of the
%                                                         underlying asset
% CallOrPut : if the option is a call, CallOrPut is 1;
%             if the option is a put,  CallOrPut is 0;
%             in default , CallOrPut is 1;
if (CallOrPut~=0)&&(CallOrPut~=1)
    error(sprintf('CallOrPut should be 1 or 0.'))
end
Paths = pricepaths(CurrentPrice,IntRate,TimeToMaturity,StdDeviation,...
                     NumOfSteps,NumOfPaths);
if CallOrPut
    PayOff = max(mean(Paths(:,2:(NumOfSteps+1)),2)-StrikePrice,0);
else
    PayOff = max(StrikePrice-mean(Paths(:,2:(NumOfSteps+1)),2),0);
end
[Price,VarOfPrice,ConInterval]=normfit(exp(-IntRate*TimeToMaturity)*PayOff)
end
