function [m,varr]=asiancrude(r,S0,sig,T,K,k,n)
% returns :
% m=value of asin call option
% var= variance of value
%Input:
% S0=initial price, K=strike price
% sig = sigma, k=number of time increments in interval [0,T]
% r the interest rate parameter. Repeats for a total of n simulations.
%e.g.[m,stderr]=asiancrude(0.03,100,0.05,0.3,100,5,10000)

v1=[]; 


mn=(r-sig^2/2)*T/k;
sd=sig*sqrt(T/k); 
Y=normrnd(mn,sd,k,n);


Y=cumsum(Y,1);
S = S0*exp(Y); 
v1= exp(-r*T)*max(mean(S,1)-K,0);

m=mean(v1);
varr=var(v1)/n;


end