{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 7 : Principles of digital data transmission"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## page no 314 prob no 7.1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "transmission rate =  32000\n"
     ]
    }
   ],
   "source": [
    "#The transmission bandwidth is given by the equation Bt=(1+r)Rb/2 and hence transmission rate is given by Rb=2Bt/(1+r)#where r=roll-off factor and 0<=r<=1. Since 'r' can take value in between 0 and 1,bandwidth varies from 2Bt to Bt.\n",
    "Bt=32000#\n",
    "r=1##assume values of Bt and r\n",
    "Rb=(2*Bt)/(1+r)#\n",
    "print \"transmission rate = \",Rb##Rb=Bt for r=1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Page no 326 Prob no 7.3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "values of C-1,C0,C1 are obtained:\n",
      "[[ 0.20939445]\n",
      " [ 1.1262026 ]\n",
      " [ 0.31692134]]\n"
     ]
    }
   ],
   "source": [
    "from numpy import mat\n",
    "# problem fig. is ggiven on page no 324. Referring the fig. we are given the values of a0,a1,a-1,a-2\n",
    "a=1#\n",
    "b=-0.3#\n",
    "c=0.1#\n",
    "d=-0.2#\n",
    "e=0.05#\n",
    "#design a three-tap (N=1) equalizer by substituting these values into eq no 7.45 of the page no 325\n",
    "A=mat([[0],[1],[0]])#\n",
    "B=mat([[a, d, e],[b, a, d],[c, b, a]])\n",
    "c=(B**-1)*A## As, A=B*C Hence c is obtained as given\n",
    "print 'values of C-1,C0,C1 are obtained:'\n",
    "print c"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## page no 334 Prob NO 7.4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Value of x : 0.0052\n",
      "error probability = 9.96e-08 \n",
      "Value of x : 96.1500\n",
      "error probability = 1.17e-04 \n",
      "error probability = 1.75e-04 \n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "# a) Find detection error probability\n",
    "#Given: Ap=1mV, 6n=192.3uV\n",
    "# The formula for polar case is given by Ap/6n\n",
    "Ap=1#\n",
    "sigma_n=192.3#\n",
    "x=Ap/sigma_n##here we have to find the value of P(e)=Q(x) from the table10.2 given on page no. 454\n",
    "print \"Value of x : %0.4f\"%x\n",
    "Q1=(0.9964)*10**(-7)#\n",
    "print \"error probability = %.2e \"%Q1 ##this is nearly equal to zero\n",
    "\n",
    "#Prob NO 7.4 b) Find detection error probability.\n",
    "#In this case, only half the bits are transmitted by no pulse, there are, on the average, only half as many pulses in the on-off case(compared to the polar). \n",
    "#To maintain the same power,we need to double the energy  of each pulse in the on-off or the bipolar case(compared to the polar).\n",
    "#Now, doubling the pulse energy is accomplished by multiplying the pulse by sqrt(2).\n",
    "#Thus, for on-off Ap is sqrt(2) times the Ap in the polar case,that is, Ap=sqrt(2)*10**-3\n",
    "x=Ap/2*sigma_n##here we have to find the value of P(e)=Q(x) from the table10.2 given on page no. 454\n",
    "print \"Value of x : %0.4f\"%x\n",
    "Q2=(1.166)*10**-4#\n",
    "print \"error probability = %0.2e \"%Q2\n",
    "#for a given power , the Ap for both the on-off and the bipolar  cases are identical. Hence P(e)=1.5 Q(x)#\n",
    "Q3=1.5*Q2#\n",
    "print \"error probability = %0.2e \"%Q3"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
