function Y = rvtransform(P,m0,n0) global m n randomize m = m0; n = n0; Y = 0*P; for xi=1:m^n x = i2c(xi); y = F(x); yi = c2i(y); Y(yi) = Y(yi) + P(xi); end return function y = F(x) % convert x into a sequence w/o repeating symbols global m n y = []; for i=1:n s = x(i); while 1 if ~ismember(s,y) y = [y s]; break; else %if y(end)>m/2 %if s > m/2 if 0 s = s - 1; if s < 1 s = m; end else s = s + 1; if s > m s = 1; end end end end end return function c=i2c(i) global m n dims = repmat(m,[1 n]); c = ind2coord(i,dims); return function i=c2i(c) global m n dims = repmat(m,[1 n]); i = coord2ind(c,dims); return