function [C0, P0] = CRRaroAD(T,S0,K,r,v,N)
% Octave/MATLAB function to price Average Rate
% Options (ARO, or Asian Options) using pathwise
% Arrow-Debreau expansions with the Cox-Ross-
% Rubinstein (CRR) binomial pricing model.
% INPUTS:                             (Example)
%    T  = expiration time in years      (0.5)
%    S0 = stock price                   (100)
%    K  = strike price                  (95)
%    r  = riskless yield per year       (0.05)
%    v  = volatility; must be >0        (0.15)
%    N  = height of the binomial tree   (5)
% OUTPUTS:
%    [C0,P0] =  Call and Put option premiums
% EXAMPLE:
%   [C0,P0]=CRRaroAD(0.5,100,95,0.05,0.15,5)
%
  [pu,up,R]=CRRparams(T,r,v,N);
  Sbar=NRTCRR(S0,up,1/up,N); % expanded S tree
  Ubar=NRTpsums(Sbar,N); % sums along each path
  Lbar=PathAD(pu*ones(N,N),R*ones(N,N),N);
  mN=2^N:(2*2^N-1); % all m-indices at expiry
  AvgN=Ubar(mN)/(N+1); % S averages at expiry
  C0=max(0,AvgN-K)*Lbar(mN)'; % Call payoff i.p.
  P0=max(0,K-AvgN)*Lbar(mN)'; % Put payoff i.p.
  return % A-D expansion of C0,P0 is completed.
end
