function [v1,v2,sc]=asian2(XT,r,s,T,K,k)
%computes the value of an asian option V1 and control variate V2
%conditional on the terminal value XT. 
% here s = sigma, initial stock value =1, K=strike, k=number of discrete intervals
%sc is value of the score function for the normal inputs with respect to 
% r the interest rate parameter.
mn=(r-s^2/2)*T/k;
sd=s*sqrt(T/k);
Y=normrnd(mn,sd,1,k);
sc=(T/k)*(log(XT)-k*mn)/(sd^2);
Y=cumsum([0 Y]);
I=(1:(k+1))/(k+1);
Y=Y-(I.*Y(k+1))+I*log(XT);
S = exp(Y);
plot((1:length(S)),S)
v1=exp(-r*T)*max(mean(S)-K,0);
v2=exp(-r*T)*max(exp(mean(Y))-K,0);