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