This is a question that I have been pondering for a while. I have not obtained a clear solution yet, here are a couple of thoughts, towards metrics based on sparsity proxies and noise estimators. Anybody wanting to share ideas and elaborate this with me is welcome.
First, this is a type of "sand pile problem". A grain of sand does not make a pile. Two neither, and so on. But if you keep on adding grains, one day you will have a pile. The exact quantity $U$ at the limit is reach is surely uncertain. Now, suppose you already have a sand pile. Remove one grain. Still a pile. You would see the point. The exact quantity $L$ where the pile becomes some grains is unclear as well, and most probably $L\neq U$.
This story is there to remind us that some isolated peaks or impulse spikes might look isolated. Yet, combine sufficiently many peaks, and you will get a perfectly fine... any signal. Fitting a large number of fine Gaussians to a curve is a problem with many solutions, and I am not aware of a stable and robust algorithm to do that job. In a word, this is probably a continuum between isolated peaks and the top signal.
A key to this issue resides for me in the notion of sparsity, or how well a signal is concentrated. The constraints in your problem are to me:
- signals can be of different length (160, 6500, 50000), so you are looking for a length invariant metric,
- peaks are positive, either with constant or decaying amplitude,
- there could be a positive non-zero baseline level (see signal 1),
- there could be some noise (positive amplitude as well).
To me, minimal ingredients required are related to the notion of sparsity:
s
- a positive threshold $\tau$, to account for background noise and offet,
- a sparse metric, applied on $x_k^\tau=\max(x_k,\tau)-\tau$ (a kind of shrinkage).
The count measure $\ell_0$ should be the most appropriate sparsity metric. one can quotient it to the number of samples to get a length-invariant measure that would yield a percentage of "not-too-low" samples. It is however a bit sensitive to the threshold. The seminal paper
Comparing Measures of Sparsity provided a useful comparison of different sparsity metrics, and ranked them when they satisfied some axioms. The Gini index came first, and this is an option for you. Other interesting metrics involved ratios of norms. They are quite interesting to me, as they were used in two of our contributions to sparse signals restoration (under noise and low-pass filtering). The works were SOOT and SPOQ:
Euclid in a Taxicab: Sparse Blind Deconvolution with Smoothed ℓ1/ℓ2 Regularization and
SPOQ ℓp-Over-ℓq Regularization for Sparse Signal Recovery Applied to Mass Spectrometry.
All the above is related to a classical bound inequality. Suppose that we have a signal $x$ of length $N$, with only $\ell_0(x)=S\le N$ non-zero samples, and $p\leq q$. Then:
$$\ell_q(x)\le\ell_p(x)\leq S^{\frac{1}{p}-\frac{1}{q}}\ell_q(x)$$
The nice thing about this inequality is that it is extremal: tThe bounds are met in interesting conditions. For the sparsest signal (only one non-zero sample),
$$\ell_q(x)=\ell_p(x)$$
For the least $S$-support sparse signal (all ones on $S$ samples), then:
$$\ell_p(x)= S^{\frac{1}{p}-\frac{1}{q}}\ell_q(x)$$
As $S$ is unknown, a quantity like:
$$ \left(\frac{\ell_p(x^\tau)}{\ell_q(x^\tau)}\right)^{\frac{qp}{q-p}}$$
could provide a rough estimate to how your signal is spiky.
Edit: the answer by @orchi_d is related: kurtosis and flatness are ratios related to $\ell_p$ norms or quasinorms.
F
, is a simple averaging filter; implemented as a bank of increasing sizesN=[63, 127, 191]
. That is, the signal filtered viaF_63
is passed toF_127
, and so on. If the signal has less than 500 points, I am usingN=[7, 15, 31]
.N
the filter kernel size. $\endgroup$