{"id":3862,"date":"2020-07-27T14:29:25","date_gmt":"2020-07-27T14:29:25","guid":{"rendered":"http:\/\/www.raymaps.com\/?p=3862"},"modified":"2022-06-03T12:18:20","modified_gmt":"2022-06-03T12:18:20","slug":"kays-single-frequency-estimator","status":"publish","type":"post","link":"https:\/\/www.raymaps.com\/index.php\/kays-single-frequency-estimator\/","title":{"rendered":"KAY\u2019s Single Frequency Estimator"},"content":{"rendered":"\n<p>As previously discussed, finding the\nfrequency of a complex sinusoid embedded in noise is a classical problem in\nSignal Processing. The problem is compounded by the fact that number of samples\navailable is usually quite small. So far, we have discussed Zero Crossing, FFT,\nMUSIC and ESPRIT methods of frequency estimation. Zero Crossing method is\nsimplest of the above four but it can detect only one sinusoid at a time. Advantage\nof Zero Crossing method is that it is computationally not that complex. It does\nnot require complex matrix manipulations as some of the other methods do. <\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Now we present another single frequency\nestimator that is quite easy to implement. It is known as Kay\u2019s Estimator [1] after\nits founder Steven M. Kay. &nbsp;Although\nquite simple to implement it achieves Cramer Rao Lower Bound (CRLB) for\nmoderate to high SNRs (SNR&gt;10dB). The basic concept of Kay\u2019s estimator is\nquite simple. It finds the phase advanced from one sample to the next and this\ngives us the frequency. Averaging is performed over the time window to get more\naccurate results. Averaging can be performed using uniform weighting or a\nweighting function defined by Kay in [1]. In the latter case CRLB is achieved\nwith equality, so there is no need to look for another estimator. <\/p>\n\n\n\n<p>Mathematically CRLB is given as:<\/p>\n\n\n\n<p>Mean Squared Error (MSE) in Angular\nFrequency=6\/(SNR*N*(N^2-1))<\/p>\n\n\n\n<p>Where N is the number of samples (set to 100 in this case) and SNR is the Signal to Noise Ratio (set to 10dB). MATLAB\/Octave code for both the methods (with different weighting functions) is given below. For the example given CRLB is calculated as:<\/p>\n\n\n\n<p>MSE=6\/(10*100*(100^2-1))=-62.22dB<\/p>\n\n\n\n<pre lang=\"MATLAB\">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%  FREQUENCY ESTIMATION USING\n%      KAY's ESTIMATOR\n%   (SINGLE FREQUENCY ONLY)\n%      www.raymaps.com\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\nclear all\nclose all\n\nN=100;\nfc=1.0e9;\nfs=20*fc;\nw=2*pi*fc\/fs;\n\nn=0:N-1;\ns=sqrt(1.0)*exp(i*w*n);\nwn=sqrt(0.1\/2)*(randn(1,N)+i*randn(1,N));\nx=s+wn;\n\n% KAY ESTIMATOR-1 (uniform weighting)\nw_est=0;\nM=N;\nfor m=1:M-1\n  w_est=w_est+(1\/(M-1))*arg((x(m))'*x(m+1));\nend\nerror_1=w-w_est;\n\n% KAY ESTIMATOR-2 (using weighting function)\nw_est=0;\nM=N;\nfor m=1:M-1\n  p(m)=6*(m)*(M-m)\/(M*(M^2-1));\n  w_est=w_est+p(m)*arg((x(m))'*x(m+1));\nend\nerror_2=w-w_est;\n<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"http:\/\/www.raymaps.com\/wp-content\/uploads\/2020\/07\/MSE-of-KAY-Frequency-Estimation-Methods-as-a-Function-of-SNR-1-1024x768.png\" alt=\"\" class=\"wp-image-3884\" srcset=\"https:\/\/www.raymaps.com\/wp-content\/uploads\/2020\/07\/MSE-of-KAY-Frequency-Estimation-Methods-as-a-Function-of-SNR-1-1024x768.png 1024w, https:\/\/www.raymaps.com\/wp-content\/uploads\/2020\/07\/MSE-of-KAY-Frequency-Estimation-Methods-as-a-Function-of-SNR-1-300x225.png 300w, https:\/\/www.raymaps.com\/wp-content\/uploads\/2020\/07\/MSE-of-KAY-Frequency-Estimation-Methods-as-a-Function-of-SNR-1-768x576.png 768w, https:\/\/www.raymaps.com\/wp-content\/uploads\/2020\/07\/MSE-of-KAY-Frequency-Estimation-Methods-as-a-Function-of-SNR-1.png 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>MSE of KAY Frequency Estimation Methods as a Function of SNR<\/figcaption><\/figure>\n\n\n\n<p><strong>Note:<\/strong> <\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>If you want the complete code for comparing the MSE of the two methods with CRLB please leave a comment below and I will get back with you.<\/li><li>Please note that as the number of samples N is increased the CRLB and Mean Squared Error (MSE) both go down. But after a time the law of diminishing returns sets in and MSE does not go down as rapidly as the CRLB.<\/li><li>The MSE also depends upon number of samples per cycle and having a very small number does not help in reducing the MSE. A few complete cycles work the best (in our code we use five complete cycles to do the estimation).<\/li><\/ol>\n\n\n\n<p><strong>Reference:<\/strong><\/p>\n\n\n\n<p>[1] S. M. Kay, \u201cA Fast and Accurate Single\nFrequency Estimator,\u201d IEEE Transactions on Acoustics, Speech, and Signal\nProcessing, vol. 37, no. 12, Dec 1989. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>The basic concept of Kay\u2019s estimator is quite simple. It finds the phase advanced from one sample to the next and this gives us the frequency. Averaging is performed over the time window to get more accurate results. Averaging can be performed using uniform weighting or a weighting function defined by Kay in [1].<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[81],"tags":[226,225,70,227,220],"class_list":["post-3862","post","type-post","status-publish","format-standard","hentry","category-fundamentals","tag-crlb","tag-estimation","tag-frequency","tag-kay","tag-phase"],"_links":{"self":[{"href":"https:\/\/www.raymaps.com\/index.php\/wp-json\/wp\/v2\/posts\/3862","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.raymaps.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.raymaps.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.raymaps.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.raymaps.com\/index.php\/wp-json\/wp\/v2\/comments?post=3862"}],"version-history":[{"count":10,"href":"https:\/\/www.raymaps.com\/index.php\/wp-json\/wp\/v2\/posts\/3862\/revisions"}],"predecessor-version":[{"id":4272,"href":"https:\/\/www.raymaps.com\/index.php\/wp-json\/wp\/v2\/posts\/3862\/revisions\/4272"}],"wp:attachment":[{"href":"https:\/\/www.raymaps.com\/index.php\/wp-json\/wp\/v2\/media?parent=3862"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.raymaps.com\/index.php\/wp-json\/wp\/v2\/categories?post=3862"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.raymaps.com\/index.php\/wp-json\/wp\/v2\/tags?post=3862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}