I have a noisy signal and a model function, for example:
x=linspace(0,20);
w=[2 6 -4 5];
y=w(1)*besselj(0,x)+w(2)*besselj(1,x)+w(3)*besselj(2,x)+w(4)*besselj(3,x);
y(randi(length(y),[1 10]))=10*rand(1,10)-5;
plot(x,y,'x')
I thought to use RANSAC to find the w
in my model, as this method is robust to noise when finding lines. However, this is not a linear problem, and I couldn't get a proper fit, probably because of the oscillatory nature of the function I'm trying to fit.
I saw matlab has a fitPolynomialRansac function, but even this fails for a a+b*x+c*x^2+d*x^3
simple case (between -1 and 1).
Any ideas how to tame RANSAC? or of a different robust to noise approach?
This is just implementing @mikuszefski's comment to use a soft L1 loss function. It does appear to be more resistant to noise: