0
$\begingroup$

I'm smoothing a signal with an little algorithme and I can control the amount of smoothing dynamically. Now it could be interesting to drive that amount with a measure depending of the frequency content. in other words if my signal is containing quick frequency it is interesting to have less of smoothing especially is the main signal is stationary.

What could I use for that? I tried mobile variance but I'm not sure this is the best method. I'm trying to avoid FFT methods or other that could dephase the signal.

second question, does kurtosis can be something relevant for that ? I think no but I would like to be sure.

thank in advance : )

PS: this isn't in real time, just sayin'

$\endgroup$
1
$\begingroup$

You could simply run your signal through some sort of high pass filter or shelf and compare the energy before and after the filter. If the ratio is high, you have a lot of high frequencies in your signal and should probably do less smoothing. If the ratio is low, there are not a lot of high frequencies and you can do more aggressive smoothing.

The frequency selectivity can be dialed in by the shape of the filter


As a simple example, the R code below runs two filters: a high pass one with unity gain at $f_s/2$ and a low pass one with unity gain at $0$. Two test signals are used: one with more low pass content, one with more high pass content.

The output is:

[1] "X: 344.6108  LPF1: 32.1535  HPF1: 15.1717  LPF2: 17.4986  HPF2: 27.7821"

The low pass filtered test signal x_test_lpf retains more energy from the low pass filter than the high pass one (32.1535 vs 15.1717). The high pass filtered test signal x_test_hpf retains more energy in the high pass output than the low pass one (17.4986 vs 27.7821).


R Code

#26668

x <- runif(1000,-1,1)

Nfilt <- 20

x_test_lpf <- c(x, filter(x,rep(1/5,5), circular = TRUE))
x_test_hpf <- c(x, filter(x,(-1)^(0:4)/5, circular = TRUE))



x_hpf_1 <- filter(x_test_lpf,(-1)^(0:(Nfilt-1))/Nfilt, circular = TRUE) # Unity gain at fs/2
x_lpf_1 <- filter(x_test_lpf,rep(1/Nfilt,Nfilt), circular = TRUE) # Unity gain at 0


x_hpf_2 <- filter(x_test_hpf,(-1)^(0:(Nfilt-1))/Nfilt, circular = TRUE) # Unity gain at fs/2
x_lpf_2 <- filter(x_test_hpf,rep(1/Nfilt,Nfilt), circular = TRUE) # Unity gain at 0


print(paste("X:", sum(x^2), " LPF1:", sum(x_lpf_1^2), " HPF1:", sum(x_hpf_1^2), " LPF2:", sum(x_lpf_2^2), " HPF2:", sum(x_hpf_2^2)))
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.