# Matlab plot of QPSK system doesn't agree perfectly with theoretical BER curves

Does anyone know if there is a simple explanation on the fact that the theoretical bit-error rate (BER) curves of a Quadrature phase-shift keying (QPSK) system are approximately 1 dB shifted from the simulated curves?

• If it's not too long, can you share your code? It could be a variety of things. – jeep9911 Jan 19 '12 at 19:39
• @George - Please post your code as requested by jeep9911! Without it, we can only guess at potential causes. I'm moving this question to our site for digital signal processing, they'll be better able to help you there. – Kevin Vermeer Jan 19 '12 at 20:31
• Perhaps you could also share the expression used to compute the theoretical BER curve? There have been many cases where the curve derived from the theoretical expression for the symbol error probability has been compared with the simulated curve for the bit error probability (and vice versa) resulting in much confusion and heartache. Errors in computing SNR, or translating a given SNR to signal amplitudes, are common too. – Dilip Sarwate Jan 19 '12 at 22:18

The simple explanation is that there is an error in your simulation. Here's one that works in MATLAB:

% number of symbols in simulation
Nsyms = 1e6;
% energy per symbol
Es = 1;
% energy per bit (2 bits/symbol for QPSK)
Eb = Es / 2;
% Eb/No values to simulate at, in dB
EbNo_dB = linspace(0, 10, 11);

% Eb/No values in linear scale
EbNo_lin = 10.^(EbNo_dB / 10);
% keep track of bit errors for each Eb/No point
bit_err = zeros(size(EbNo_lin));
for i=1:length(EbNo_lin)
% generate source symbols
syms = (1 - 2 * (randn(Nsyms,1) > 0)) + j * (1 - 2 * (randn(Nsyms, 1) > 0));
syms_noisy = sqrt(Es/2) * syms + sqrt(Eb/(2*EbNo_lin(i))) * (randn(size(syms)) + j * randn(size(syms)));
% recover symbols from each component (real and imaginary)
syms_rec_r = sign(real(syms_noisy));
syms_rec_i = sign(imag(syms_noisy));
% count bit errors
bit_err(i) = sum((syms_rec_r ~= real(syms)) + (syms_rec_i ~= imag(syms)));
end
% convert to bit error rate
bit_err = bit_err / (2 * Nsyms);

% calculate theoretical bit error rate, functionally equivalent to:
% bit_err_theo = qfunc(sqrt(2*EbNo_lin));
bit_err_theo = 0.5*erfc(sqrt(2*EbNo_lin)/sqrt(2));
figure;
semilogy(EbNo_dB, bit_err, 'bx', EbNo_dB, bit_err_theo, 'r', 'MarkerSize', 10, 'LineWidth', 2);
xlabel('Eb/No (dB)');
ylabel('Bit error rate');
title('QPSK bit error rate');
legend('Simulation','Theory');
grid on;


Note that the theoretical expression for bit error rate for BPSK/QPSK modulation is:

$$P_b = Q\left(\sqrt{\frac{2E_b}{N_0}}\right)$$

keeping in mind that $E_b$ is the energy per information bit. The somewhat subtle distinction between $E_b$ and $E_s$, the energy per symbol, is something that often trips up people new to the subject. This difference also explains why QPSK and BPSK have the same bit error rate when expressed as a function of $\frac{E_b}{N_0}$; you don't get any bit-error performance benefit by moving to QPSK, although you can achieve a given bit rate with less occupied bandwidth.

• As I noted in my comment on the main question, another source of confusion is that the symbol error rate is $$P_s= 2Q\left(\sqrt{\frac{2E_b}{N_0}}\right) - \left[Q\left(\sqrt{\frac{2E_b}{N_0}}\right)\right]^2$$ since the symbol is incorrect if at least one bit is demodulated incorrectly, the bit errors in in-phase and quadrature branches are independent, and $$P(A\cup B) = P(A) + P(B) - P(A\cap B) = P(A) + P(B) - P(A)P(B) = 2p-p^2$$ for independent events of probability $p$ – Dilip Sarwate Jan 20 '12 at 17:53
• Can I ask a question? How do you calculate the energy per bit? I mean, in reality, it doesn't equal 1. So can you explain in reality how do I caculate the energy per bit? Thank you very much! – Khanh Nguyen Sep 25 '13 at 11:45
• @KhanhNguyen: Assuming you have achieved timing synchronization, you can estimate the energy per symbol by averaging the accumulated squared magnitude of the observed signal over many symbol periods. That is, $E_s \approx \frac{1}{M} \sum_{k=0}^K \sum_{n=0}^{N_s} |x[kN_s + n]|^2$, where $M$ is the number of symbols that you average over and $N_s$ is the number of samples that you have per symbol. For QPSK, there are 2 bits per symbol, so $E_b = \frac{E_s}{2}$. – Jason R Sep 25 '13 at 12:24