An option for 10th degree polynomials but no weighted linear least squares. Seriously? Jesse
1 Comment
Time DescendingIt's only a few lines of code to make your own.
PolyOrder = 10; % Order of polynomial
N = 50; % Length of signal
B = rand(N, 1); % Signal
B(floor([.1, .7]*N)) = [-1, 1]*10; % Outliers
w = ones(N, 1); % Weights
w(floor([.1, .7]*N)) = 0;
W = diag(w);
A = linspace(-1, 1, N)'.^(0:PolyOrder); % Dictionary
xw = (A'*W*A)\(A'*W*B); % WLS fit
x = (A'*A)\(A'*B); % LS fit
plot(B, 'k');
hold on;
plot(A*x, 'b');
plot(A*xw, 'm');
hold off;
legend('Data', 'LS', 'WLS');
Sign in to participate
