There's a few possible problems with taking a running maximum of all the accelerometer samples within your window.
- You'll miss large negative excursions. This may not be a problem; the absolute value of excursions might be enough for your application.
- You'll miss two large excursions in the one time window.
- The actual times the peaks occur at will be lost, or at least be inaccurate. For example, if adjacent windows have peaks at the beginning and then at the end, the actual time between them will be nearly two window lengths, but the reported time will be one window length
- All values will tend to be positive, which will bias the "background" acceleration.
I've written some
R code to simulate discarding 49 out of every 50 values, and only keeping the maximum one in a window. The raw data are the black circles in the plot. The maximum values are the green circles; the minimum values are the red circles.
R Code Below
N <- 1000
acc <- rnorm(N)/5
Nspikes <- 10
spike_indices <- runif(Nspikes,1,N)
spike_values <- runif(Nspikes,-10,10)
acc[spike_indices] <- spike_values
decimationFactor <- 50
idx <- 1
mx <- rep(0,length(seq(1,length(acc),decimationFactor)))
mn <- rep(0,length(seq(1,length(acc),decimationFactor)))
for (k in seq(1,length(acc),decimationFactor))
idxs = seq(max(1,k), min(length(acc), k+decimationFactor-1),1)
mx[idx] = max(acc[idxs])
mn[idx] = min(acc[idxs])
idx <- idx + 1