# Negative values from High Pass filtering

I come from Fluid Mechanics domain so pardon me for asking a naive and fundamental question.

I am trying to perform high pass filtering on a set of positive real numbers (~Energy) using FFT. However, the result I obtain has a lot of negative values. I tried to quantify how many of them are negative and it seems $\sim50\%$ of these values are negative.

I tried looking up for an answer and I saw a general approach used in Image processing domain, where people offset these negative values or use some threshold. But in my case, I can't use either of these techniques because I need to look at some statistical quantities after the filtering process.

So I want to ask why do these negative numbers appear for a purely positive input and if so, are there any solutions for it?

• As some posters request, please show us a plot of your original data and the high-pass filtered data. Upload an image somewhere, and we can inline it for you if you don't have the rep. – Peter K. Aug 28 '13 at 13:29
• That's what high pass filters do. Is there some reason you believe it shouldn't have negative values? – endolith Aug 28 '13 at 19:28

A high pass filter has some properties that are similar to taking a derivative. The derivative of a function that is always positive will be negative wherever the slope is negative. There's nothing you can do about it. For example, take the function $f(t) = 400 + \sin \omega t$. This wiggles around between 399 and 401 (very positive), yet the derivative is $\omega \cos \omega t$. So the derivative (i.e., high-pass filter), will wiggle between $-\omega$ and $\omega$.

• Just what I was going to say. The analogy between highpass filtering and differentiation is a good intuitive explanation for what the OP is seeing. – Jason R Aug 28 '13 at 12:46
• Ok, that example really helped me understand how HPF behaves. However, the magnitude of negative values is relatively large and so it contaminates the results when I try to use a band-pass filter. So does this mean that the dataset I am looking at has very large $\omega$ causing this? – Sidhha Aug 28 '13 at 12:49
• Look at the data in the time domain (or add a plot to your question). Do you see any parts where the signal's derivative would be large and negative (i.e. regions where it decreases rapidly)? That's one way to look at it. One question I would ask is why you expect the result to be nonnegative. What is the end application for the filtered data? – Jason R Aug 28 '13 at 13:05
• Large values means that you have very abrupt changes in your data. It more likely means you have noise than that you have any real high frequency signal. High-pass filtering (and derivatives) tend to emphasize noise rather than signal. Typically the reason that you would high pass filter would be because you are looking for sharp transitions. (In image processing you find edges by taking the squared gradient (i.e., high-pass filter) and then keep only the pixels along locally-maximal ridges.) – Wandering Logic Aug 28 '13 at 13:18

A high pass filter will remove a large portion to all of the 0 Hz component or DC offset from a signal. That's similar to subtracting the mean average, which for a normally distributed signal will make around half of the signal negative (since it was below the original average mean).

If you want the mean to be the same after a high pass filter, you could always add it back.

If you don't care about the actual mean value, you could also add an arbitrarily large positive offset to make sure the sum was always positive.

• Do you suggest I add the mean of the original data to the high-pass filtered results? I tried that, and it may not necessarily result in positive real. In other words, the negative values in HPF results are comparable to the mean value in the case I am looking at. – Sidhha Aug 28 '13 at 8:01
• What's wrong with negative values? I appreciate you're looking at "energy" and as such a negative quantity is a bit counter-intuitive, but in performing this filtering operation you are explicitly removing the DC offset. It is then perfectly normal for a signal to have positive and negative excursions. – Speedy Aug 28 '13 at 10:49
• The problem surfaces when I switch to band pass filter because the negative components are relatively large and they contaminate the results completely which is definitely not what one would expect. I then observed it was occurring due to HPF and hence, the question I asked. – Sidhha Aug 28 '13 at 12:44

You can try to perform a band-pass filter instead, between some value very near to 0 (very large period of the sinusoidal) and your current cutoff frequency.