I'm a software engineer that has been given the task of calculating the SNR of a communications signal that is represented by an array of complex numbers. I'm not quite sure how to proceed.
Here's what I have as input data:
An array complex numbers of length $N$. This is the representation of the signal for which I need to calculate the SNR. Within this array, there is a "marker signal" of length $M$ (where $M < N$) that is of known shape (let's say it's a single cycle of a sin function). For sake of scale, let's say $N = 1000$ and $M = 100$.
After doing some research on SNR, I've clearly discovered that I'm in over my head; however, I've attempted to formulate an approach...for which I need expert critique. So here it is:
It seems to calculate SNR, I need to know what the signal is without the noise and separately the noise itself, i.e. I need to get a array of complex numbers that represent the signal without noise, and an array of complex numbers that represent the corresponding noise, such that if I add these two arrays together, I get the original signal.
The only way I know to separate the original signal array into the two parts described above is to know the shape of underlying signal. In this case, I do know that for the "marker signal" portion of the array. Thus my approach would be, assuming that an SNR calculation for the "marker signal" of length $M$ would provide a reasonable estimate for the entire sample of length $N$.
- Create an array of length $M$ from the "marker signal" portion of the original length $N$ array. I can do this because I know where the marker is suppose to be in the $N$ array. Let's call it $O$.
- Create an array of length $M$ that matches the known "marker signal" shape, i.e. a noiseless marker. Let's call it $S$.
- Generate an $M$-length noise array by simply subtracting $S$ from $O$. Let's call this $E$. It should hold an estimate of the noise that overlaid the "marker" portion of the original signal.
- Separately calculate the RMS of $S$ and the RMS of $E$
- Finally, calculate SNR as
$$\text{SNR} = 20\text{log}_{10}\bigg(\frac{S_{RMS}}{E_{RMS}}\bigg) $$
My specific questions are:
a) In general, is this approach correct for an SNR estimate? If not, do you have an advice on how to appropriately handle this situation?
b) when separating the noise from the raw signal, I'm a little concerned about the amplitude of my reference marker signal not being the same as the underlying signal in the raw data. It seems like some sort of normalization should be done, but I'm not sure how I would do that. For example, in the image below, the orange signal is the raw "marker signal" and the blue is the reference marker signal. As you can see, they have the same shape but different magnitudes, so simply subtracting the reference from the raw would give me something other than just the noise.
Thanks!
Edit
I'm providing a few more details of my situation in response to @Engineer.
I didn't mention in my original post that I am locating the reference marker within the raw signal by performing a correlation. So, the process is:
capture a block of incoming samples. The number of samples is selected such that I'm sure that I'll have at least one marker within the block.
slide a window across the block of samples, the width of which is the same as the marker signal, and calculate the correlation between the samples within the window and the samples from the reference marker signal using the following equation (I actually used a normalized form of the equation because I was worried about the possible amplitude mis-match):
- the result of the equation above is a complex number, so use the magnitude of this complex value as the actual correlation value. If I plot this for all window positions within the block of data, I get a plot similar that that below. NOTE: this plot is shows ideal conditions, with real data it is obviously much noisier than this.
With all that said, and trying to connect that with your response using my small mind, I have the following questions:
Is $R_{xy}$ in your response the same as the peak correlation value that I'm calculating? If not, is it because I'm using a normalized form of this correlation calculation?
To calculate $P_x$ and $P_y$, do I simply use the RMS equation?
If I understand 1 and 2 above correctly, I would calculate SNR as:
Thanks again for taking the time to respond.