% Proakis analytical curves for i.i.d. Rayleigh fading & MRC (equal SNRs)
%
% snr_dB = Overall average SNR in dB
% L = number of branches (L = 1,...,4)
%
% janm Oct. 10, 2008
% ******************************************************************************


function [BER] = proakis_equalSNRs(snr_dB,L)

snr_lin = 10.^(snr_dB/10);    % Overall average SNR linear 

nue = sqrt(snr_lin./(1+snr_lin));

if L==1
  % N=1 path
  BER =(1 - nue)./2;
elseif L==2
  % N=2 paths
  sum_N2 = 1 + (1 + nue); 
  BER = ( (1/2^2) * (1 - nue).^2 ) .* sum_N2;
elseif L==3
  % N=3 paths
  sum_N3 = 1 + 3*(1 + nue)/2 + 3*((1 + nue).^2)/2; 
  BER = ( (1/2^3) * (1 - nue).^3 ) .* sum_N3;
elseif L==4
  % N=4 paths
  sum_N4 = 1 + 4 * 1/2 * (1 + nue)  +  10 * 1/4 * (1 + nue).^2  +  20 * 1/8 * (1 + nue).^3; 
  BER = ( (1/2^4) * (1 - nue).^4 ) .* sum_N4;
end



