function K = randsig(m,n) dims = repmat([m],[1 n]); K = ones(m^n,1); while 1 sig = sign(randn(m,1)); if ~all(sig==sig(1)) break end end for xind = 1:m^n x = ind2coord(xind,dims); s = sig(x(1)); K(xind) = K(xind)*s; end return