function ESS=ess(W) % computes the effective sample size sum=0; M=length(W); for i=1:M sum=sum+(M*W(i)-1)^2; end cvt2=1/M*sum; ESS=M/(1+cvt2);