domingo, 10 de febrero de 2013

[IT] Homework 1. Noisy channel simulation

The activity of this blog entry was to program some scripts to simulate the transmision of some random information through a Binary Symmetric Channel. Also we have to analyze the final results of the simulation

Basically what I did was to program a script in Python to generate the necesary parameters to run the simulation, the parameters are:

  • Word length (binary word) 
  • Maximum length of the words
  • The length of the word traduced in power of two
  • Quantity of words of the same size
  • The numbers of repetitions of transmit a word throught the binary symmetric channel
  • Frecuency of appearance of zeros in each word
  • The probability that a zero continues being a zero after the transmission
  • The probability that a one continues being a one after the transmission.

My initial conditions was:

Word length
Max. word len.
Power of two
from 0 to 10
Zero frecuency
[from 0.1 to 0.8]
Probability of zeros
[0.45, 0.55, 0.70, 0.80, 0.95]
Probability of ones
[0.3, 0.60, 0.80, 0.95, 0.90]
Quantity of words

After that, I was generated all the possible combinations of parameters. I build that in a Python script.

The simulation follows these steps:
  1. The Python simulation script receives the parameters length of word, frecuency of appearance of zeros in each word, the probability of zeros, the probability of ones, the number of repetitions of transmission of each word.
  2. The script builds a word of length "l" containing only zeros and ones (bits).
  3. The script takes that word and simulates the transmission of the word throught a binary symmetric channel, here is where the probabilities of zeros and ones works, sometimes changing some bits. This action is repeated "r" times.
  4. In each transmission the script compares the receives word with the transmitted word, counting only the ocurrences where both words are the same.
  5. The scripts calculates an average with the number of repetitions and the number of a successfull transmissions.
  6. The script returns the calculated average.

After that, another Python script takes the calculated average and writes the value on a temporal file, this process is repeated depending on the amount of words of each length that will be generated, in this case, 30 words. This means that 30 words will be transmitted 30 times each through the channel.

The scripts changes the value of the frecuency of zeros after 30 words with 30 repetitions each, in each change, a script written in awk calculates the average and the standard deviation of each run and saves the result on a special file with special format to plot the results with gnuplot.


Python script that automate all the simulation process:

Python script that simulates the binary symmetric channel:

Awk script that calculates the average and standard deviation in each run:


The purpose of the experiment is to determine the reliability of the channel at different probabilities of zeros and ones, to visualize the results I plot them in a chart using gnuplot. This is the result:

Where the x axis represents the size of the word in powers of two, the y axis represents the different frecuencies of zero, the z axis represents the percentage of a successful transmision through the channel and the color's gradients represents the standard deviation.

As we can see, the reliability of the channel decreases exponentially when the word length increases, with a word length of 5 (32 bits) the reliability of the channel is already below than 20 percent.


With a rapid analysis we can recognize the shape of the graph, it's like an exponential function with a negative input and . To provee that I plot each graph in pairs and also I plot the graph of an exponential function, to be more precise, the function:


Where the input x is negative, the input A controls the width of the curve, and the B input displaces the curve on the x axis.

The are the results:

So, we can accurate the behavior of the channel using the function exp((-x*0.6)+4.5), we can't reproduce exactly the behavior of the channel but the exponential function is a good aproximation.

Using the standard deviation, this is the comparison between the analytical function's plot and experimental result's plot:


1 comentario:

  1. Check your spelling for minor mistakes. A complete program and a thorough report. 5+5.