How Can I Detect Peaks and Regions of Highest Variance in a 1D Signal?

I'm not a signal processing person at all so hopefully I'm not asking an obvious question (if I am, I'd appreciate any resources that would help give more context).

I have a 1D vector where the values give temperature at some position. I want to find out where the regions of greatest change are and then mark off those regions for future sampling.

My current method is to take the gradient of the signal and either convolve that gradient with some window or average past signals (in time) with this current one. Both approaches are in an effort to reduce noise and/or overfitting to one particular signal in time. Once I get this smoothed signal, I fit a Gaussian function to it and mark off the regions that are within 4 standard deviations of the mean. (If there are multiple peaks, the hope is that the smoothing or convolution will make it smoothed enough so that the Gaussian will capture both peaks, but this fails sometimes which is why I'm looking for something more robust. An extension to this would be to try and fit multiple Gaussians as well, if it is a sensible idea in general.)

Here's a quick plot I was using to compare the different smoothing windows (the original signal is real data that I'm working with, which usually only has one large peak but may have more).

(Also, the convolution seems to center the peaks away from where they actually are. If there are no better solutions, how can I stop that from happening? EDIT: Peter K.'s comment helped me fix this silly error.)

But this is a pretty noob approach that I just came up with. Is there a better way? The places I want to sample around are obviously regions around local maxima, but defining what local maxima means seems to be tricky, and it doesn't always give great results. In general, though, I will want to sample continuously around the regions of peaks, i.e. if I have two peaks, one at 5m and one at 10m, I want to sample between, say, 2m and 13m, not chopping it in the middle. It may be worth noting that these signals are a snapshot in time, so perhaps I can take advantage of past signals as well somehow?

EDIT: As per @Phonon's suggestion, I thought I'd add some more detail about the problem. The signal is actually coming from a sensor that samples along a water column in a lake (the x-axis of the graph is depth, up to 40 meters). Seasonal changes and other variables (like wind speed, humidity, etc.) will create changes in this water column. What I'm trying to do is to figure out how to catch the most pertinent information using the least amount of energy (the sensor has to move up and down). So hence the approach to find the maximum gradient and threshold around it for sampling. However, I wonder if there is a better way. Another one I can think of is to look at how much the signal varies at various depths over time, and sample those regions. I was mainly wondering if there existed some standard methods to do this sort of thing already.

• When you smooth the data, how long a "window" do you use? e.g. is it half the length of the data? Something smaller? Unless you're careful, smoothing the data with a filter of length $N$ will (assuming the filter is symmetric) generally move the peaks by $N/2$.
– Peter K.
Sep 5 '13 at 17:06
• D'oh! Thanks for the comment, I was immediately able to fix that. Sep 5 '13 at 17:14
• @PeterK. Can you make your comment an answer? It looks like it solved the OP's problem. Oct 27 '13 at 5:17
• @Phonon Sorry, it didn't actually. I am still curious about a way to [robustly] detect peaks with large variance (Peter's correction just fixed a minor issue for me). Oct 27 '13 at 16:10
• @hadsed Are you still looking for an answer? I'll put a bounty on it if you do. Also, posting your data somewhere and putting more detail into your question should help. Oct 27 '13 at 19:32

1. Create a smoothed signal using $N$ points averaging window to estimate the local average.
2. On the smoother signal I'd find an approximation which regularizes the ${L}_{1}$ norm of the gradient.