# BER vs Eb/N0 (db) Curve

So, I was trying to plot BER (Bit Error Rate) vs. Eb/No (in dB) curve using Python. Here is what I get,

Eb/N0 is in dB on the x-axis

But I know that this is not the correct graph.

Here is my code.

import matplotlib.pyplot as plt
import numpy as np
from scipy.special import erfc

def Q(x):
return 0.5*erfc(x*(2**(-0.5)))

ebnodb = np.arange(0.1, 12, 0.01)
ebno = [10**(i*0.1) for i in ebnodb]
ebno = np.array(ebno)
y = Q(np.sqrt(2*ebno))

plt.plot(ebnodb, y)
plt.xlabel("Eb/N0")
plt.ylabel("BER")
plt.show()


Can someone figure out, what am I doing wrong?

• it is because you are plotting the log of $y$. – Ahmad Bazzi Apr 7 at 15:51

## 1 Answer

Usually, such figures show the error rate on a log scale, and $$E_b/N_0$$ in dB. So you would specify $$E_b/N_0$$ in dB, then convert it to a ratio, and use that value to evaluate the formula for the bit error rate (as you did). Then you plot the logarithm of the error rate as a function of $$E_b/N_0$$ in dB. So the main problem is that you used a linear scale for the BER instead of a logarithmic scale.

If you do things right, you'll end up with something like this:

• Thank you very much @Matt. I got the right curve now. – Himanshu Sharma Apr 7 at 3:56