REAL_TO_CORR Maps reals to correlations. s = real_to_corr(t) maps the real number t to the correlation s in [-1,1]. Works as the inverse function of corr_to_real, hence corr_to_real(real_to_corr(x)) is (nearly) equal to x. See also CORR_TO_REAL. created by Benedikt Rudolph DATE: 20-Aug-2012
0001 function s = real_to_corr(t) 0002 %REAL_TO_CORR Maps reals to correlations. 0003 % 0004 % s = real_to_corr(t) maps the real number t to the correlation s in [-1,1]. 0005 % Works as the inverse function of corr_to_real, hence 0006 % corr_to_real(real_to_corr(x)) is (nearly) equal to x. 0007 % 0008 % See also CORR_TO_REAL. 0009 % 0010 % created by Benedikt Rudolph 0011 % DATE: 20-Aug-2012 0012 0013 s = zeros(size(t)); 0014 idx = (t>=0); 0015 s(idx) = 1-1./(t(idx)+1); 0016 s(~idx) = -1-1./(t(~idx)-1); 0017 end