GNU Radio Manual and C++ API Reference  3.8.1.0
The Free & Open Software Radio Ecosystem
mpsk_snr_est.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2011,2012 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef INCLUDED_DIGITAL_MPSK_SNR_EST_H
24 #define INCLUDED_DIGITAL_MPSK_SNR_EST_H
25 
26 #include <gnuradio/digital/api.h>
27 #include <gnuradio/gr_complex.h>
28 
29 namespace gr {
30 namespace digital {
31 
32 /*!
33  * \brief A block for computing SNR of a signal.
34  * \ingroup measurement_tools_blk
35  *
36  * \details
37  * Below are some ROUGH estimates of what values of SNR each of
38  * these types of estimators is good for. In general, these offer
39  * a trade-off between accuracy and performance.
40  *
41  * \li SNR_EST_SIMPLE: Simple estimator (>= 7 dB)
42  * \li SNR_EST_SKEW: Skewness-base est (>= 5 dB)
43  * \li SNR_EST_M2M4: 2nd & 4th moment est (>= 1 dB)
44  * \li SNR_EST_SVR: SVR-based est (>= 0dB)
45  */
46 typedef enum {
47  SNR_EST_SIMPLE = 0, // Simple estimator (>= 7 dB)
48  SNR_EST_SKEW, // Skewness-base est (>= 5 dB)
49  SNR_EST_M2M4, // 2nd & 4th moment est (>= 1 dB)
50  SNR_EST_SVR // SVR-based est (>= 0dB)
52 
53 /*! \brief A parent class for SNR estimators, specifically for
54  * M-PSK signals in AWGN channels.
55  * \ingroup snr_blk
56  */
58 {
59 protected:
60  double d_alpha, d_beta;
61  double d_signal, d_noise;
62 
63 public:
64  /*! Constructor
65  *
66  * Parameters:
67  * \param alpha: the update rate of internal running average
68  * calculations.
69  */
70  mpsk_snr_est(double alpha);
71  virtual ~mpsk_snr_est();
72 
73  //! Get the running-average coefficient
74  double alpha() const;
75 
76  //! Set the running-average coefficient
77  void set_alpha(double alpha);
78 
79  //! Update the current registers
80  virtual int update(int noutput_items, const gr_complex* input);
81 
82  //! Use the register values to compute a new estimate
83  virtual double snr();
84 
85  //! Returns the signal power estimate
86  virtual double signal();
87 
88  //! Returns the noise power estimate
89  virtual double noise();
90 };
91 
92 
93 //! \brief SNR Estimator using simple mean/variance estimates.
94 /*! \ingroup snr_blk
95  *
96  * A very simple SNR estimator that just uses mean and variance
97  * estimates of an M-PSK constellation. This estimator is quick
98  * and cheap and accurate for high SNR (above 7 dB or so) but
99  * quickly starts to overestimate the SNR at low SNR.
100  */
102 {
103 private:
104  double d_y1, d_y2;
105  double d_counter;
106 
107 public:
108  /*! Constructor
109  *
110  * Parameters:
111  * \param alpha: the update rate of internal running average
112  * calculations.
113  */
114  mpsk_snr_est_simple(double alpha);
116 
117  int update(int noutput_items, const gr_complex* input);
118  double snr();
119 };
120 
121 
122 //! \brief SNR Estimator using skewness correction.
123 /*! \ingroup snr_blk
124  *
125  * This is an estimator that came from a discussion between Tom
126  * Rondeau and fred harris with no known paper reference. The
127  * idea is that at low SNR, the variance estimations will be
128  * affected because of fold-over around the decision boundaries,
129  * which results in a skewness to the samples. We estimate the
130  * skewness and use this as a correcting term.
131  *
132  * This algorithm only appears to work well for BPSK signals.
133  */
135 {
136 private:
137  double d_y1, d_y2, d_y3;
138  double d_counter;
139 
140 public:
141  /*! Constructor
142  *
143  * Parameters:
144  * \param alpha: the update rate of internal running average
145  * calculations.
146  */
147  mpsk_snr_est_skew(double alpha);
149 
150  int update(int noutput_items, const gr_complex* input);
151  double snr();
152 };
153 
154 
155 //! \brief SNR Estimator using 2nd and 4th-order moments.
156 /*! \ingroup snr_blk
157  *
158  * An SNR estimator for M-PSK signals that uses 2nd (M2) and 4th
159  * (M4) order moments. This estimator uses knowledge of the
160  * kurtosis of the signal (\f$k_a)\f$ and noise (\f$k_w\f$) to make its
161  * estimation. We use Beaulieu's approximations here to M-PSK
162  * signals and AWGN channels such that \f$k_a=1\f$ and \f$k_w=2\f$. These
163  * approximations significantly reduce the complexity of the
164  * calculations (and computations) required.
165  *
166  * Reference:
167  * D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR
168  * estimation techniques for the AWGN channel," IEEE
169  * Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000.
170  */
172 {
173 private:
174  double d_y1, d_y2;
175 
176 public:
177  /*! Constructor
178  *
179  * Parameters:
180  * \param alpha: the update rate of internal running average
181  * calculations.
182  */
183  mpsk_snr_est_m2m4(double alpha);
185 
186  int update(int noutput_items, const gr_complex* input);
187  double snr();
188 };
189 
190 
191 //! \brief SNR Estimator using 2nd and 4th-order moments.
192 /*! \ingroup snr_blk
193  *
194  * An SNR estimator for M-PSK signals that uses 2nd (M2) and 4th
195  * (M4) order moments. This estimator uses knowledge of the
196  * kurtosis of the signal (k_a) and noise (k_w) to make its
197  * estimation. In this case, you can set your own estimations for
198  * k_a and k_w, the kurtosis of the signal and noise, to fit this
199  * estimation better to your signal and channel conditions.
200  *
201  * A word of warning: this estimator has not been fully tested or
202  * proved with any amount of rigor. The estimation for M4 in
203  * particular might be ignoring effectf of when k_a and k_w are
204  * different. Use this estimator with caution and a copy of the
205  * reference on hand.
206  *
207  * The digital_mpsk_snr_est_m2m4 assumes k_a and k_w to simplify
208  * the computations for M-PSK and AWGN channels. Use that
209  * estimator unless you have a way to guess or estimate these
210  * values here.
211  *
212  * Original paper:
213  * R. Matzner, "An SNR estimation algorithm for complex baseband
214  * signal using higher order statistics," Facta Universitatis
215  * (Nis), no. 6, pp. 41-52, 1993.
216  *
217  * Reference used in derivation:
218  * D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR
219  * estimation techniques for the AWGN channel," IEEE
220  * Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000.
221  */
223 {
224 private:
225  double d_y1, d_y2;
226  double d_ka, d_kw;
227 
228 public:
229  /*! Constructor
230  *
231  * Parameters:
232  * \param alpha: the update rate of internal running average
233  * calculations.
234  * \param ka: estimate of the signal kurtosis (1 for PSK)
235  * \param kw: estimate of the channel noise kurtosis (2 for AWGN)
236  */
237  snr_est_m2m4(double alpha, double ka, double kw);
239 
240  int update(int noutput_items, const gr_complex* input);
241  double snr();
242 };
243 
244 
245 //! \brief Signal-to-Variation Ratio SNR Estimator.
246 /*! \ingroup snr_blk
247  *
248  * This estimator actually comes from an SNR estimator for M-PSK
249  * signals in fading channels, but this implementation is
250  * specifically for AWGN channels. The math was simplified to
251  * assume a signal and noise kurtosis (\f$k_a\f$ and \f$k_w\f$) for M-PSK
252  * signals in AWGN. These approximations significantly reduce the
253  * complexity of the calculations (and computations) required.
254  *
255  * Original paper:
256  * A. L. Brandao, L. B. Lopes, and D. C. McLernon, "In-service
257  * monitoring of multipath delay and cochannel interference for
258  * indoor mobile communication systems," Proc. IEEE
259  * Int. Conf. Communications, vol. 3, pp. 1458-1462, May 1994.
260  *
261  * Reference:
262  * D. R. Pauluzzi and N. C. Beaulieu, "A comparison of SNR
263  * estimation techniques for the AWGN channel," IEEE
264  * Trans. Communications, Vol. 48, No. 10, pp. 1681-1691, 2000.
265  */
267 {
268 private:
269  double d_y1, d_y2;
270 
271 public:
272  /*! Constructor
273  *
274  * Parameters:
275  * \param alpha: the update rate of internal running average
276  * calculations.
277  */
278  mpsk_snr_est_svr(double alpha);
280 
281  int update(int noutput_items, const gr_complex* input);
282  double snr();
283 };
284 
285 } /* namespace digital */
286 } /* namespace gr */
287 
288 #endif /* INCLUDED_DIGITAL_MPSK_SNR_EST_H */
double d_beta
Definition: mpsk_snr_est.h:60
SNR Estimator using simple mean/variance estimates.
Definition: mpsk_snr_est.h:101
snr_est_type_t
A block for computing SNR of a signal.
Definition: mpsk_snr_est.h:46
Definition: mpsk_snr_est.h:48
Definition: mpsk_snr_est.h:47
A parent class for SNR estimators, specifically for M-PSK signals in AWGN channels.
Definition: mpsk_snr_est.h:57
#define DIGITAL_API
Definition: gr-digital/include/gnuradio/digital/api.h:30
Definition: mpsk_snr_est.h:49
~mpsk_snr_est_simple()
Definition: mpsk_snr_est.h:115
Signal-to-Variation Ratio SNR Estimator.
Definition: mpsk_snr_est.h:266
std::complex< float > gr_complex
Definition: gr_complex.h:27
double d_signal
Definition: mpsk_snr_est.h:61
SNR Estimator using skewness correction.
Definition: mpsk_snr_est.h:134
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition: basic_block.h:43
SNR Estimator using 2nd and 4th-order moments.
Definition: mpsk_snr_est.h:171
Definition: mpsk_snr_est.h:50
SNR Estimator using 2nd and 4th-order moments.
Definition: mpsk_snr_est.h:222
~mpsk_snr_est_svr()
Definition: mpsk_snr_est.h:279
~mpsk_snr_est_m2m4()
Definition: mpsk_snr_est.h:184
~snr_est_m2m4()
Definition: mpsk_snr_est.h:238
~mpsk_snr_est_skew()
Definition: mpsk_snr_est.h:148