[SciPy-User] frequency components of a signal buried in a noisy time domain signal
Sat Feb 27 04:43:57 CST 2010
I will not answer your questions to Anne then (I could, but you asked her :)
), but I'll give you another advice, given that you are new to signal
Whatever you do, please do not use the scipy's snr function call to
calculate the SNR in signal processing.
I'll illustrate the problem with the 'statistical SNR' in signal processing
with 3 closely related and simple examples.
1. Infinitely long sinusoidal signal with additive white noise
Let x(t)=s(t)+n(t)=A sin(2\pi f t) + n(t)
Power of the signal component can be found as P_s=1/(2T) \int_T^T s^2(t) dt
= A^2/2, and let the power of noise be P_n=var(n) = 1.
If, we chose A=100, then intuitively, we know that the SNR is large, and
indeed: SNR = P_s/ P_N = A^2/2 = 5000
On the other hand, if you use statistical definition (used in optical
astronomy, and scipy and implemented in SCIPY), you would conclude quite the
SNR = \mu_s / signa_n = mean(s) / signa_n= 0/1 = 0, and that would be the
case regardless of what the value for A is.
2. Discrete time signal with finite duration
Let's take this same signal and sample it in a such way that we have 100
cycles of a sinusoid:
Using sampled signal definitions for powers, you get:
P_s = np.mean(s**2) = 4997.5
and you can calculate the power of the noise either as:
>>> np.var(n) = 0.97726608241925972
the same way as the power of the signal:
>>> np.mean(n**2) = 0.977977713
The results will slightly differ, and that has to do with biased/unbiased
which is pretty close to analog domain case with infinitely long signal.
Using the scipy approach, you would however conclude the following:
-5.7148860210947362e-15 (which comes close to zero).
3. Same example, but let's take fractional number of cycles.
>>> t=np.linspace(0,0.5+np.pi/800,2000+int(5*np.pi)) # this is 100 cycles +
1/4 of a cycle
>>> P_s = np.mean(s**2)
5117.8701015651177 # very close to the two results above
But, using the other definition:
As you can see, your SNR would be a function of the frequency of the signal
(that is, it would matter how you truncate the cycles) and it wouldn't
matter much what is the amplitude of the signal.
Just my 2 cents,
On 27 February 2010 04:41, Nils Wagner <firstname.lastname@example.org> wrote:
> On Fri, 26 Feb 2010 16:32:01 -0500
> Anne Archibald <email@example.com> wrote:
> > Hi,
> > Looking at a periodic signal buried in noise is a
> > problem, with many techniques for attacking it. You
> >really need to be
> > a little more specific about what you want to do. For
> >example, is your
> > input signal really a sinusoid, or does it have harmonic
> >content? Are
> > you trying to detect a weak periodic signal or are you
> >trying to
> > extract the features of a strong periodic signal? Is
> >your signal
> > exactly periodic, does it have some (deterministic or
> >random) wander,
> > or are you looking for the power spectrum of a broadband
> > If your input data are non-uniformly sampled, everything
> >becomes more
> > difficult (and computationally expensive), but there are
> > (e.g. the Lomb-Scargle periodogram).
> > Anne
> Hi Anne,
> Thank you very much for your hints !
> BTW, a BSD licensed code for the Lomb-Scargle periodogram
> is available at
> I am newbie to signal processing.
> Is there a good introduction that you can recommend ?
> There are so many books on signal processing. It should
> cover engineering applications.
> What makes a signal weak/strong periodic ?
> The signals come from real-life application (pressure /
> acceleration data).
> Do I need a filter before I apply FFT ?
> What would you do if you know nothing about the origin of
> the signal ?
> How can I distinguish between deterministic and random
> wander ?
> SciPy-User mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User