Moving window of standard deviation
Show older comments
I am currently using movstd(A,k), and I want to detect values that is more than a certain threshold value at every array of local k-point standard deviation values. Is there any possible way that I can do that?
Answers (1)
Bjorn Gustavsson
on 23 Mar 2022
To do this it seems that it would be sensible to combine movstd and movmean (or movmedian). Then something like this ought to illustrate one way to do this:
% Mock up some trivial example-data
A = randn(31,1);
k = 7;
thresh = 0.1;
% Sliding statistics
mstdA = movstd(A,k); % or movmad - which measure of spread to use might depend on the
mavgA = movmean(A,k); % or movmedian, distribution of the local "noise-variations"
% Detect points further from the moving average
iPos = find(A>(mavgA+mstdA)+thresh);
iNeg = find(A<(mavgA-mstdA)-thresh);
% Illustrating plots
plot(A,'.-')
hold on
plot(mavgA,'.-')
plot(mavgA+mstdA,'.-')
plot(mavgA-mstdA,'.-')
plot(iPos,A(iPos),'ro')
plot(iNeg,A(iNeg),'bo')
HTH
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!