function [p,ci]=AsianMCCV(s0,k,r,t,sigma,nsamples,nrepl,npilot)
trypath=assetpaths1(s0,r,sigma,nsamples,npilot);
stocksum=sum(trypath,2);
pp=mean(trypath(:,2:(nsamples+1),2);
trypayoff=exp(-r*t)*max(0,pp-x);
matcov=cov(stocksum,trypayoff);
dt=t/nsamples;
expsum=s0*(1-exp((nsamples+1)*r*dt))/(1-exp(r*dt));
controlvars=zeros(nrepl,1);
for i=1:nrepl
stockpath=assetpaths1(s0,r,sigma,t,nsamples,1);
payoff(i)=exp(-r*t)*max(0,mean(stockpath(2:(nsamples+1)))-x);
controlvars(i)=payoff(i)+c*(sum(stockpath)-expsum);
end
[p,aux,ci]=normfit(controlvars);
function spaths=assetpahts1(s0,mu,sigma,nsteps,nrepl)
dt=t/nsteps;
nudt=(mu-0.5*sigma^2)*dt;
sidt=sigma*sqrt(dt);
increments=nudt+sidt*randn(nrepl,nsteps);
logpaths=cumsum([log(s0)*ones(nrepl,1),increments],2)
spaths=exp(logpaths);
感觉trypath也不是向量啊,怎么可以对列求和或对行求和(红色标记出来)