# Calculating SNR from Frequency-time domain

I tried to analyse the time-frequency of specific appliances. As it shows in the following frequency-time graph I have High frequency noise from different appliances here. 4096 is the number of frequency divisions. So in the data I have, across a spectrum of 0-1Mhz, there are 4096 divisions. In other words, each "bin", holds the amount of energy at that frequency. 1Mhz/4096 = 244.14Hz, thus, each bin from 0-4095 represents energy averaged over roughly 244.14Hz. (244,14 vectors per second)

I tried to analyse each bin before the time before 1.34334165, and plotted the 4096 point FFT vector as frequency vs. power. I am not sure why it is 500 Khz, but I think the High Frequency signal is sampled at 1 MHz and FFTs are computed to get 2048 frequency data points from DC to 500 kHz So the question is, I need to calculate the SNR of each bin represented in the graph. I was following the thread here on how to calculate SNR from frequency domain signal, but I was wondering if this answer is correct. I couldn't understand the 50 leakage and, as I was wondering too, is the inputsignal the sum of the magnitudes of all the 4096 bins?

This is probably not going a particularly satisfactory or useful answer for you. SNR is a ubiquitous concept in Signal Processing and one would expect a correct straightforward calculation on data would be available and it basically is: $$SNR=\frac{\text{Signal Power or Energy}}{\text{Noise Power or Energy}}$$ so you just look at your spectra and identify the signal and noise and make the calculations. This is usually straightforward to do theoretically. In some applications these identifications are easy and in others less so and looking at your data, not much looks obvious. A FFT of the data didn't make what is signal or noise obvious to me and if were obvious to you, you probably would not be asking so $$\text{Correct} \;SNR \ne \frac{\text{Hard to tell Signal Power or Energy}}{\text{Hard to tell Noise Power or Energy}}.$$

Instead, $$\text{Plausible} \;SNR = \frac{\text{Plausible Signal Power or Energy}}{\text{Plausible Noise Power or Energy}}.$$ is likely to be more successful. I've actually had to present these issues to management and at the end been asked if this was "correct". Saying yes has usually been the "correct" answer.

Getting back to you data, the frequency time graph has some quiet spots that are probably your best candidates for a plausible noise estimate. This assumes, that the noise is stationary, but looking at everything else in the time frequency plot, this seems plausible. Extract a Noise Power estimate from the quiet segments and average as many as possible. Also I'm guessing that the signals are of finite duration. $$\text{Plausible} \;(S+N)R = \frac{\int_T (\text{Plausible Signal + Noise Power}) \; dt}{\text{Plausible Noise}\times T}.$$ where $T$ is the signal duration.

Some details, We have Parseval's Identity, $$\sum_{n=0}^{N-1} x[n] = \frac{1}{N}\sum_{k=0}^{N-1} \mid X[k] \mid ^2$$ and the variance of a sum of $N$ independent random variables $$\sigma^2_{\text{Total}}= \sum _{k=0}^{N} \sigma_k^2.$$ The random variables don't have to be Gaussian, they just need to have a variance.

For long DFT's noise bins are approximately independent, summing the noise power present in each bin is a reasonably same assumption if the noise is approximately flat across the spectrum.

If your signal is known, the energy can be calculated using Parseval's Identity. If your signal has random characteristics, The signal bins are probably not independent and summing bin power may not be the best plausible method. If you have enough data, you can estimate the covariance $$Pwr=\mathbf{x}_{sig}^H \mathbf{R}\mathbf{x}_{sig}$$ which is a power quantity.

For complicated signal and noise scenarios the most reasonable method is to derive a model, not necessarily a full model, and simulate your SNR estimation process.

The answer to 50 is a heuristic to account foe signal leakage outside the nominal signal limits.