GNU Radio 3.7.1 C++ API
mpsk_snr_est.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2011,2012 Free Software Foundation, Inc.
00004  * 
00005  * This file is part of GNU Radio
00006  * 
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  * 
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 
00023 #ifndef INCLUDED_DIGITAL_MPSK_SNR_EST_H
00024 #define INCLUDED_DIGITAL_MPSK_SNR_EST_H
00025 
00026 #include <gnuradio/digital/api.h>
00027 #include <gnuradio/gr_complex.h>
00028 
00029 namespace gr {
00030   namespace digital {
00031 
00032     /*!
00033      * \brief A block for computing SNR of a signal.
00034      * \ingroup measurement_tools_blk
00035      *
00036      * \details
00037      * Below are some ROUGH estimates of what values of SNR each of
00038      * these types of estimators is good for. In general, these offer
00039      * a trade-off between accuracy and performance.
00040      *
00041      * \li SNR_EST_SIMPLE:  Simple estimator (>= 7 dB)
00042      * \li SNR_EST_SKEW:    Skewness-base est (>= 5 dB)
00043      * \li SNR_EST_M2M4:    2nd & 4th moment est (>= 1 dB)
00044      * \li SNR_EST_SVR:     SVR-based est (>= 0dB)
00045      */
00046     typedef enum {
00047       SNR_EST_SIMPLE = 0,   // Simple estimator (>= 7 dB)
00048       SNR_EST_SKEW,         // Skewness-base est (>= 5 dB)
00049       SNR_EST_M2M4,         // 2nd & 4th moment est (>= 1 dB)
00050       SNR_EST_SVR           // SVR-based est (>= 0dB)
00051     } snr_est_type_t;
00052 
00053     /*! \brief A parent class for SNR estimators, specifically for
00054      *  M-PSK signals in AWGN channels.
00055      *  \ingroup snr_blk
00056      */
00057     class DIGITAL_API mpsk_snr_est
00058     {
00059     protected:
00060       double d_alpha, d_beta;
00061 
00062     public:
00063       /*! Constructor
00064        *
00065        *  Parameters:
00066        *  \param alpha: the update rate of internal running average
00067        *  calculations.
00068        */
00069       mpsk_snr_est(double alpha);
00070       virtual ~mpsk_snr_est();
00071 
00072       //! Get the running-average coefficient
00073       double alpha() const;
00074 
00075       //! Set the running-average coefficient
00076       void set_alpha(double alpha);
00077 
00078       //! Update the current registers
00079       virtual int update(int noutput_items,
00080                          const gr_complex *input);
00081 
00082       //! Use the register values to compute a new estimate
00083       virtual double snr();
00084     };
00085 
00086 
00087     //! \brief SNR Estimator using simple mean/variance estimates.
00088     /*! \ingroup snr_blk
00089      *
00090      *  A very simple SNR estimator that just uses mean and variance
00091      *  estimates of an M-PSK constellation. This esimator is quick
00092      *  and cheap and accurate for high SNR (above 7 dB or so) but
00093      *  quickly starts to overestimate the SNR at low SNR.
00094      */
00095     class DIGITAL_API mpsk_snr_est_simple :
00096       public mpsk_snr_est
00097     {
00098     private:
00099       double d_y1, d_y2;
00100   
00101     public:
00102       /*! Constructor
00103        *
00104        *  Parameters:
00105        *  \param alpha: the update rate of internal running average
00106        *  calculations.
00107        */
00108       mpsk_snr_est_simple(double alpha);
00109       ~mpsk_snr_est_simple() {}
00110 
00111       int update(int noutput_items,
00112                  const gr_complex *input);
00113       double snr();
00114     };
00115 
00116 
00117     //! \brief SNR Estimator using skewness correction.
00118     /*!  \ingroup snr_blk
00119      *
00120      *  This is an estimator that came from a discussion between Tom
00121      *  Rondeau and fred harris with no known paper reference. The
00122      *  idea is that at low SNR, the variance estimations will be
00123      *  affected because of fold-over around the decision boundaries,
00124      *  which results in a skewness to the samples. We estimate the
00125      *  skewness and use this as a correcting term.
00126      */
00127     class DIGITAL_API mpsk_snr_est_skew :
00128       public mpsk_snr_est
00129     {
00130     private:
00131       double d_y1, d_y2, d_y3;
00132   
00133     public:
00134       /*! Constructor
00135        *
00136        *  Parameters:
00137        *  \param alpha: the update rate of internal running average
00138        *  calculations.
00139        */
00140       mpsk_snr_est_skew(double alpha);
00141       ~mpsk_snr_est_skew() {}
00142 
00143       int update(int noutput_items,
00144                  const gr_complex *input);
00145       double snr();
00146     };
00147 
00148 
00149     //! \brief SNR Estimator using 2nd and 4th-order moments.
00150     /*! \ingroup snr_blk
00151      *
00152      *  An SNR estimator for M-PSK signals that uses 2nd (M2) and 4th
00153      *  (M4) order moments. This estimator uses knowledge of the
00154      *  kurtosis of the signal (k_a) and noise (k_w) to make its
00155      *  estimation. We use Beaulieu's approximations here to M-PSK
00156      *  signals and AWGN channels such that k_a=1 and k_w=2. These
00157      *  approximations significantly reduce the complexity of the
00158      *  calculations (and computations) required.
00159      *
00160      *  Reference:
00161      *  D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR
00162      *  estimation techniques for the AWGN channel," IEEE
00163      *  Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000.
00164      */
00165     class DIGITAL_API mpsk_snr_est_m2m4 :
00166       public mpsk_snr_est
00167     {
00168     private:
00169       double d_y1, d_y2;
00170   
00171     public:
00172       /*! Constructor
00173        *
00174        *  Parameters:
00175        *  \param alpha: the update rate of internal running average
00176        *  calculations.
00177        */
00178       mpsk_snr_est_m2m4(double alpha);
00179       ~mpsk_snr_est_m2m4() {}
00180 
00181       int update(int noutput_items,
00182                  const gr_complex *input);
00183       double snr();
00184     };
00185 
00186 
00187     //! \brief SNR Estimator using 2nd and 4th-order moments.
00188     /*!  \ingroup snr_blk
00189      *
00190      *  An SNR estimator for M-PSK signals that uses 2nd (M2) and 4th
00191      *  (M4) order moments. This estimator uses knowledge of the
00192      *  kurtosis of the signal (k_a) and noise (k_w) to make its
00193      *  estimation. In this case, you can set your own estimations for
00194      *  k_a and k_w, the kurtosis of the signal and noise, to fit this
00195      *  estimation better to your signal and channel conditions.
00196      *
00197      *  A word of warning: this estimator has not been fully tested or
00198      *  proved with any amount of rigor. The estimation for M4 in
00199      *  particular might be ignoring effectf of when k_a and k_w are
00200      *  different. Use this estimator with caution and a copy of the
00201      *  reference on hand.
00202      *
00203      *  The digital_mpsk_snr_est_m2m4 assumes k_a and k_w to simplify
00204      *  the computations for M-PSK and AWGN channels. Use that
00205      *  estimator unless you have a way to guess or estimate these
00206      *  values here.
00207      *
00208      *  Original paper: 
00209      *  R. Matzner, "An SNR estimation algorithm for complex baseband
00210      *  signal using higher order statistics," Facta Universitatis
00211      *  (Nis), no. 6, pp. 41-52, 1993.
00212      *
00213      *  Reference used in derivation:
00214      *  D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR
00215      *  estimation techniques for the AWGN channel," IEEE
00216      *  Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000.
00217      */
00218     class DIGITAL_API snr_est_m2m4 :
00219       public mpsk_snr_est
00220     {
00221     private:
00222       double d_y1, d_y2;
00223       double d_ka, d_kw;
00224   
00225     public:
00226       /*! Constructor
00227        *
00228        *  Parameters:
00229        *  \param alpha: the update rate of internal running average
00230        *  calculations.
00231        *  \param ka: estimate of the signal kurtosis (1 for PSK)
00232        *  \param kw: estimate of the channel noise kurtosis (2 for AWGN)
00233        */
00234       snr_est_m2m4(double alpha, double ka, double kw);
00235       ~snr_est_m2m4() {}
00236 
00237       int update(int noutput_items,
00238                  const gr_complex *input);
00239       double snr();
00240     };
00241 
00242 
00243     //! \brief Signal-to-Variation Ratio SNR Estimator.
00244     /*! \ingroup snr_blk
00245      *
00246      *  This estimator actually comes from an SNR estimator for M-PSK
00247      *  signals in fading channels, but this implementation is
00248      *  specifically for AWGN channels. The math was simplified to
00249      *  assume a signal and noise kurtosis (k_a and k_w) for M-PSK
00250      *  signals in AWGN. These approximations significantly reduce the
00251      *  complexity of the calculations (and computations) required.
00252      *
00253      *  Original paper:
00254      *  A. L. Brandao, L. B. Lopes, and D. C. McLernon, "In-service
00255      *  monitoring of multipath delay and cochannel interference for
00256      *  indoor mobile communication systems," Proc. IEEE
00257      *  Int. Conf. Communications, vol. 3, pp. 1458-1462, May 1994.
00258      *
00259      *  Reference:
00260      *  D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR
00261      *  estimation techniques for the AWGN channel," IEEE
00262      *  Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000.
00263      */
00264     class DIGITAL_API mpsk_snr_est_svr :
00265       public mpsk_snr_est
00266     {
00267     private:
00268       double d_y1, d_y2;
00269   
00270     public:
00271       /*! Constructor
00272        *
00273        *  Parameters:
00274        *  \param alpha: the update rate of internal running average
00275        *  calculations.
00276        */
00277       mpsk_snr_est_svr(double alpha);
00278       ~mpsk_snr_est_svr() {}
00279 
00280       int update(int noutput_items,
00281                  const gr_complex *input);
00282       double snr();
00283     };
00284 
00285   } /* namespace digital */
00286 } /* namespace gr */
00287 
00288 #endif /* INCLUDED_DIGITAL_MPSK_SNR_EST_H */