function LLR = Gaussian_pdf(y,M,Sgw) % y - is the estimated received complex signal % M - is the modulation type, i.e. M=2 for BPSK % Sgw - is the noise variance. if M==2 LLR= -2*(y);%./Sgw^2; elseif M==4 yi=real(y); yq=imag(y); b0=-2*yi;%./Sgw^2; b1=-2*yq;%./Sgw^2; % b0= alfa*b0; % b1= alfa*b1; LLR = reshape([b0;b1],1,2*length(y)); elseif M==16 yi = real(y); yq = imag(y); % Sgw=sqrt(2); b0 = Gaussian_1(yi,Sgw,1,-1); b11 = Gaussian_1(yi,Sgw,-1,-3); b12 = Gaussian_1(yi,Sgw,1,3); b1=min(b11,b12); b2 = Gaussian_1(yq,Sgw,1,-1); b31 = Gaussian_1(yq,Sgw,-1,-3); b32 = Gaussian_1(yq,Sgw,1,3); b3=min(b31,b32); % % b0=2*yi; % b2=2*yq; % b21=(yi-2); % b22=-(yi+2); % b1=2*min(b21,b22); % b31=(yq-2); % b32=-(yq+2); % b3=2*min(b31,b32); LLR=reshape([b0;b1;b2;b3],1,log2(M)*length(b0)); end end function ba = Gaussian_1(y,Sgw,a,b) P1=exp(-(y-a).^2/(2*Sgw^2)); P2=exp(-(y-b).^2/(2*Sgw^2)); ba =log(P1./P2); end