Regular LDPC Codes on the BEC

This code is provided as supplementary material of the lecture Channel Coding 2 - Advanced Methods.

This code illustrates

  • Convergence analysis of regular LDPC codes on the binary erasure channel (BEC)

In [1]:
import numpy as np
import matplotlib.pyplot as plot
from ipywidgets import interactive
import ipywidgets as widgets
import math
%matplotlib inline

In this notebook, we look at the performance evaluation of regular $[d_{\mathtt{v}},d_{\mathtt{c}}]$ LDPC codes. We first consider the fixed-point equation before looking at the evolution of the message erasure probability as a function of the erasures


In [2]:
def fixedpoint(epsilon, dv, dc):
    plot.figure(3)    
    x = np.linspace(0, 1, num=1000)
    y = epsilon * (1 - (1-x)**(dc-1))**(dv-1) - x
    print('Rate of the code %1.2f' % (1-dv/dc))
    if any(e >= 0 for e in y[2:]):
        color = (1, 0, 0)
    else:
        color = (0, 0.59, 0.51)
        
    plot.rcParams.update({'font.size': 16})
    plot.plot(x, y, color=color)
    plot.xlabel(r'$\xi$')
    plot.ylabel(r'$f(\epsilon,\xi)-\xi$')
    plot.xlim(0,1)
    plot.grid()
    plot.show()

This code evaluates the fixed point equation for regular $[d_{\mathtt{v}},d_{\mathtt{c}}]$ LDPC codes. The fixed point equation in this case reads $$f(\epsilon,\xi)-\xi <= 0\quad \forall \xi \in (0,1]$$ with $$f(\epsilon,\xi) = \epsilon\left(1-(1-\xi)^{d_{\mathtt{c}}-1}\right)^{d_{\mathtt{v}}-1}$$

The plot below shows the evaluate of $f(\epsilon,\xi)-\xi$. If $f(\epsilon,\xi)-\xi \leq 0$ for any $\xi > 0$, then decoding is possible and the curve is displayed with blue color. In the other case, it is displayed with red color.

You can use the sliders to control the values $[d_{\mathtt{v}},d_{\mathtt{c}}]$ of the code and the channel parameter $\epsilon$ (epsilon).


In [6]:
interactive_plot = interactive(fixedpoint, \
                               epsilon=widgets.FloatSlider(min=0.0,max=1,step=0.001,value=0.5, continuous_update=True, description=r'\(\epsilon\)',layout=widgets.Layout(width='50%')), \
                               dv = widgets.IntSlider(min=2,max=10,step=1,value=3, continuous_update=False, description=r'\(d_{\mathtt{v}}\)'), \
                               dc = widgets.IntSlider(min=3, max=20, step=1, value=6, continuous_update=False, description=r'\(d_{\mathtt{c}}\)'))

output = interactive_plot.children[-1]
output.layout.height = '350px'
interactive_plot


In the following, we show the update equation of the code, i.e., how the code behaves as a function of the iteration counter for the first 100 iterations.


In [4]:
def f_iter(epsilon, dv, dc):
    num_iter = 101
    plot.figure(4)        
    xi = np.zeros(num_iter)
    xi[0] = epsilon
        
    for k in np.arange(1,num_iter):
        xi[k] = epsilon * (1 - (1-xi[k-1])**(dc-1))**(dv-1)    
        
    print('Rate of the code %1.2f' % (1-dv/dc))
    if any(e == 0 for e in xi[:]):
        color = (0, 0.59, 0.51)
    else:
        color = (1,0,0)
        
    plot.rc('text', usetex=True)
    plot.rc('font', family='serif')   
    plot.rcParams.update({'font.size': 16})

    plot.plot(np.arange(1,num_iter+1), xi, color=color)
    plot.xlabel(r'Iterations $\ell$')
    plot.ylabel(r'$\xi_\ell = f(\epsilon,\xi_{\ell-1})$')
    plot.ylim(0,max(epsilon+0.1,dv/dc))
    plot.xlim(0,num_iter)
    plot.grid()
    plot.show()

In [5]:
epsilon_values = np.arange(0,1,0.001)
interactive_update = interactive(f_iter, \
                               epsilon=widgets.SelectionSlider(options=[("%1.3f"%i,i) for i in epsilon_values], value=0.5, continuous_update=False, description=r'\(\epsilon\)',layout=widgets.Layout(width='50%')), \
                               dv = widgets.IntSlider(min=2,max=10,step=1,value=3, continuous_update=False, description=r'\(d_{\mathtt{v}}\)'), \
                               dc = widgets.IntSlider(min=3, max=20, step=1, value=6, continuous_update=False, description=r'\(d_{\mathtt{c}}\)'))

output = interactive_update.children[-1]
output.layout.height = '350px'
interactive_update



In [ ]: