function R = radaveF(A,P) global m n F R = 0; for xi=1:m^n x = i2c(xi,m,n); FX = getFX(A,x); for si=1:2^n sig = 2*(i2c(si,2,n)-1)-1; SIG = repmat(sig,[size(A,2) 1]); Z = max(sum(SIG.*(FX),2)/n); R = R + Z * P(xi) / 2^n; end end return function FX = getFX(calF,x) [m,F] = size(calF); n = length(x); FX = zeros(F,n); for f=1:F for i=1:n FX(f,i) = calF(x(i),f); end end return function c=i2c(i,m,n) dims = repmat(m,[1 n]); c = ind2coord(i,dims); return