I have no background in statistics so please be nice. With my little knowledge, I also did not find any similar posts or at least posts that I could understand.
Here is my problem, I have a variety of signals with no clear trends that range from simple converging exponentials to what looks like a random walk with jumps (worst case), see below. These signals are noisy with a more or less constant noise that I know follows a normal distribution.
I want to measure the standard deviation of this noise, I am not interested in its mean because it's unstable.
I use a rather unconventional approach to estimate the standard deviation, but it works well enough. I have also quickly checked the maths; in theory, the output is the standard deviation. At the start, I was using the standard deviation of the moving standard deviation on 2 points with Bessel's correction i.e std(movstd(x,2,0),1) which can be simplified in the following code.
time = linspace(0,80,300)';
true_sigma = 1;
noise = true_sigma*randn(size(time));
true_sigma = std(noise);
process = cumsum(0.3*randn(size(time)));
jump_point = 50;
process(time>jump_point) = process(time>jump_point)+15;
signal = process+noise;
s_list = nan(size(time));
for k=1:length(time)
d = gradient(signal(1:k));
s_list(k) = std(d)*2/sqrt(2);
end
subplot(2,1,1);
plot(time,signal); grid on; xlim([time(1) time(end)]); title('Signal'); xlabel('Time (min)')
subplot(2,1,2);
plot(s_list); grid on; xlim([1 length(s_list)]); title('Estimated Standard Deviation'); xlabel('Samples'); yline(true_sigma,'--r');
legend('\sigma_{est}','\sigma_{true}')
Here is the output of this code. The signal is representative of the worst-case scenario but is still likely to happen. You can see that when the signal jumps the estimated standard deviation jumps too and will take a long time to converge again.
Here is what I want : Solution 1: Be immune to this kind of jump OR mitigate them OR have a quicker convergence Solution 2: Have a confidence indicator that allows me to pick the best/most likely guess of the run.
I did look into the Bayesian interference, but to be honest I do not understand how to do it and I have no idea where to start.
Thank you for your help.