I am looking for a fast double summation method for the following calculation.
X=[0:N-1]; Y=[0:N-1];
Z=ExEy[exp(-(X-Y)^2)];
Thus, in MATLAB,
X=[0:N-1]; Y=[0:N-1];
for n=1:N
Zy = sum(exp(-(X-Y))^2)) / N;
end
Z = sum(Zy) / N;
As shown above, firstly I tried "for loop" and "sum()" function in matlab. But for large number of sequence this method is too slow if the sample size N is large.
Are there anyone who know faster calculation for this problem?