IT++ Logo
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 double EXIT::Gaussian_Fct::operator()(double x) const
36 {
37  return (1.0/std::sqrt(_sigma*itpp::m_2pi))*std::exp(-itpp::sqr(x-(_sigma/2.0))/(2.0*_sigma))*::log2(1+std::exp(-x));
38 }
39 
40 double EXIT::extrinsic_mutual_info(const itpp::vec &obs, const itpp::bvec &cond, const int &N)
41 {
42  //initialize histogram
43  itpp::Histogram<double> hist(itpp::min(obs), itpp::max(obs), N);//common definition interval for both PDFs
44 
45  //conditional PDF knowing that a bit of 0 was emitted
46  itpp::ivec idx = itpp::find(cond==itpp::bin(0));
47  itpp::vec cond_obs = obs(idx);
48  hist.reset();//start counting
49  hist.update(cond_obs);
50  itpp::vec left_pdf = hist.get_pdf();//the pdf is computed without taking into account the interval length (step)
51  itpp::ivec left_int = itpp::find(left_pdf!=0);//integration interval for the left PDF
52 
53  //conditional PDF knowing that a bit of 1 was emitted
54  idx = itpp::find(cond==itpp::bin(1));
55  cond_obs = obs(idx);
56  hist.reset();//restart counting
57  hist.update(cond_obs);
58  itpp::vec right_pdf = hist.get_pdf();
59  itpp::ivec right_int = itpp::find(right_pdf!=0);//integration interval for the right PDF
60 
61  //mutual extrinsic information
62  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))));
63  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)
64  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))));
65  IE += itpp::sum(right_half)-0.5*(right_half(0)+right_half(right_half.length()-1));//numerical integration
66  IE *= 0.5;
67 
68  return IE;
69 }
70 
71 }//namespace itpp
72 
SourceForge Logo

Generated on Sat Jul 6 2013 10:54:22 for IT++ by Doxygen 1.8.2