function th=smooth_theta2(acc0,decay) racc=acc0; racc(acc0<0)=0; th=racc(1)*ones(size(racc)); for i=2:numel(racc) if racc(i)*(1+decay)>th(i-1) th(i)=racc(i); else th(i)=th(i-1)*(1-decay); end end