IT++ Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
exit.cpp
Go to the documentation of this file.
1 
29 #include <itpp/comm/exit.h>
30 #include <itpp/stat/histogram.h> //histogram class for mutual information computation
31 #include <itpp/base/itcompat.h>
32 
33 namespace itpp
34 {
35 
36 double EXIT::sigma2A;//allocate memory for static member variable
37 
38 double EXIT::extrinsic_mutual_info(const itpp::vec &obs, const itpp::bvec &cond, const int &N)
39 {
40  //initialize histogram
41  itpp::Histogram<double> hist(itpp::min(obs), itpp::max(obs), N);//common definition interval for both PDFs
42 
43  //conditional PDF knowing that a bit of 0 was emitted
44  itpp::ivec idx = itpp::find(cond==itpp::bin(0));
45  itpp::vec cond_obs = obs(idx);
46  hist.reset();//start counting
47  hist.update(cond_obs);
48  itpp::vec left_pdf = hist.get_pdf();//the pdf is computed without taking into account the interval length (step)
49  itpp::ivec left_int = itpp::find(left_pdf!=0);//integration interval for the left PDF
50 
51  //conditional PDF knowing that a bit of 1 was emitted
52  idx = itpp::find(cond==itpp::bin(1));
53  cond_obs = obs(idx);
54  hist.reset();//restart counting
55  hist.update(cond_obs);
56  itpp::vec right_pdf = hist.get_pdf();
57  itpp::ivec right_int = itpp::find(right_pdf!=0);//integration interval for the right PDF
58 
59  //mutual extrinsic information
60  itpp::vec left_half = itpp::elem_mult(left_pdf(left_int), itpp::log2(itpp::elem_div(2.0*left_pdf(left_int), left_pdf(left_int)+right_pdf(left_int))));
61  double IE = itpp::sum(left_half)-0.5*(left_half(0)+left_half(left_half.length()-1));//numerical integration without taking into account the inteval length (see conditional PDF computation)
62  itpp::vec right_half = itpp::elem_mult(right_pdf(right_int), itpp::log2(itpp::elem_div(2.0*right_pdf(right_int), left_pdf(right_int)+right_pdf(right_int))));
63  IE += itpp::sum(right_half)-0.5*(right_half(0)+right_half(right_half.length()-1));//numerical integration
64  IE *= 0.5;
65 
66  return IE;
67 }
68 
69 double EXIT::gaussian_fct(const double x)
70 {
71  return (1.0/std::sqrt(sigma2A*itpp::m_2pi))*std::exp(-itpp::sqr(x-(sigma2A/2.0))/(2.0*sigma2A))*::log2(1+std::exp(-x));
72 };
73 
74 }//namespace itpp
75 
SourceForge Logo

Generated on Fri Mar 21 2014 17:14:13 for IT++ by Doxygen 1.8.1.2