# Automatically detect "bimodal" curves in a large number of short time series

So, I have a huge number of amplitude modulated waves and I am attempting to determine which modulation parameter modulates each time series. To do this, I folded each time series over at the repetition frequency of the modulator wave, to produce an averaged modulation index for each time series.

Here is a (not particularly good, but convenient to produce) example. The left curve, if smoothed, produces a single preferred time point. The right produces two (a weak preference at 7, and a strong preference at 17). Technically the same is somewhat true of the one on the left but, for the sake of argument, lets ignore that for now.

I'd like to do something analogous to kernel density estimation for each time series, and then automatically determine the peaks from this shape. I know these aren't really distributions, but what I would like to do is automatically determine: A) the number of peaks per time series, B) the locations of these peaks. B sounds easy to me if I can do A. I suppose this means smoothing the curves and defining the local maxima via some sort of window, but thought some of you statistics experts might know of a proper method for this sort of thing.

kernel density estimation for each time series

The term you're looking for is probably kernel smoothing; and perhaps kernel regression/local (polynomial) regression. There are other forms of smoothing; you might have spline smoothing for example, and (relatedly), smoothing filters (e.g. Whittaker-Henderson / Hodrick-Prescott type smoothing).

The bandwidth of kernel smoothing will need to partly relate to the smallest features you want to pick up. Note that identification of peaks in smooth curves relates to derivates and optimal bandwidths for the derivative are different from the optimal bandwidth for the original function.

However, because these are time series, the usual assumption of independence will be suspect; take care with that.

http://en.wikipedia.org/wiki/Kernel_smoother

http://en.wikipedia.org/wiki/Kernel_regression

http://en.wikipedia.org/wiki/Smoothing_spline

http://en.wikipedia.org/wiki/Hodrick%E2%80%93Prescott_filter

Also somewhat related:

http://en.wikipedia.org/wiki/Exponential_smoothing

http://en.wikipedia.org/wiki/Decomposition_of_time_series

--

Edit: I meant to mention when I posted before that there are also "peak finding" methods based on fitting what are essentially mixtures of scaled gaussians (or other scaled peaked distributions like say the Cauchy).

If you're contemplating a maximum of two peaks (unimodal vs bimodal), the elimination of the possibility of many peaks makes this a fairly easy one to consider implementing, and it should work fairly well.

--

Do you have the numbers that generated those plots? I may be able to illustrate a couple of these.

• Cheers, thank you for the detailed and informative response. Here is a subset of the data: 800 24 point time series. I've also included some labels here, but they are unnecessary for your purpose. The exact time series above are not in the dataset provided, but many similar ones are. dropbox.com/sh/p1od9e4vx8ky66a/igt2OkNDbQ
– jdv
Commented Apr 26, 2013 at 21:49
• apologies for the delay... I didn't know how to get your attention. @Glen_b
– jdv
Commented May 19, 2013 at 15:57