Understand values differences between smooth and smoothdata functions
Hi,
I’m working on rlowess smoothing and I was wondering why I observe output differences between smooth and smoothdata functions, despite the fact that they are supposed to be similar.
I wrote a small piece of code:
% Sample one-dimensional data
x = 1:100;
data = cos(2*pi*0.05*x+2*pi*rand) + 0.5*randn(1,100);
% Apply rlowess smoothing with smooth
smoothedData2 = smooth(data, 9, ‘rlowess’);
% Apply rlowess smoothing with smoothdata
smoothedData3 = smoothdata(data, ‘rlowess’, 9);
smoothedData2
smoothedData3
isequal(smoothedData2, smoothedData3)
% Plot the original and smoothed data
figure;
plot(x, data, ‘o’);
hold on;
plot(x, smoothedData2, ‘–‘);
plot(x, smoothedData3, ‘:’);
legend(‘Original Data’, ‘Smoothed Data 2’, ‘Smoothed Data 3’);
title(‘Comparison of Smoothing Methods’);
% Calculate the differences
diff2_3 = smoothedData2(:) – smoothedData3(:);
% Display the differences
disp(‘Difference between smoothedData2 and smoothedData3:’);
disp(diff2_3);
As you can see, the graph is similar for both cases, but the values are different.
I also tried to change the method to ‘lowess’, and the differences there are only on the first and last entries, so I’m guessing that the moving window isn’t calculated similarly in both cases (however, I can’t find a difference in the window calculation from the documentation here and here).
To sum up, my two questions are:
Is there a difference in window calculation between smooth and smoothdata for ‘lowess’ method
Apart from this difference, could there be another issue with the calculation of robust weights for example in ‘rlowess’ method.
Thank you!Hi,
I’m working on rlowess smoothing and I was wondering why I observe output differences between smooth and smoothdata functions, despite the fact that they are supposed to be similar.
I wrote a small piece of code:
% Sample one-dimensional data
x = 1:100;
data = cos(2*pi*0.05*x+2*pi*rand) + 0.5*randn(1,100);
% Apply rlowess smoothing with smooth
smoothedData2 = smooth(data, 9, ‘rlowess’);
% Apply rlowess smoothing with smoothdata
smoothedData3 = smoothdata(data, ‘rlowess’, 9);
smoothedData2
smoothedData3
isequal(smoothedData2, smoothedData3)
% Plot the original and smoothed data
figure;
plot(x, data, ‘o’);
hold on;
plot(x, smoothedData2, ‘–‘);
plot(x, smoothedData3, ‘:’);
legend(‘Original Data’, ‘Smoothed Data 2’, ‘Smoothed Data 3’);
title(‘Comparison of Smoothing Methods’);
% Calculate the differences
diff2_3 = smoothedData2(:) – smoothedData3(:);
% Display the differences
disp(‘Difference between smoothedData2 and smoothedData3:’);
disp(diff2_3);
As you can see, the graph is similar for both cases, but the values are different.
I also tried to change the method to ‘lowess’, and the differences there are only on the first and last entries, so I’m guessing that the moving window isn’t calculated similarly in both cases (however, I can’t find a difference in the window calculation from the documentation here and here).
To sum up, my two questions are:
Is there a difference in window calculation between smooth and smoothdata for ‘lowess’ method
Apart from this difference, could there be another issue with the calculation of robust weights for example in ‘rlowess’ method.
Thank you! Hi,
I’m working on rlowess smoothing and I was wondering why I observe output differences between smooth and smoothdata functions, despite the fact that they are supposed to be similar.
I wrote a small piece of code:
% Sample one-dimensional data
x = 1:100;
data = cos(2*pi*0.05*x+2*pi*rand) + 0.5*randn(1,100);
% Apply rlowess smoothing with smooth
smoothedData2 = smooth(data, 9, ‘rlowess’);
% Apply rlowess smoothing with smoothdata
smoothedData3 = smoothdata(data, ‘rlowess’, 9);
smoothedData2
smoothedData3
isequal(smoothedData2, smoothedData3)
% Plot the original and smoothed data
figure;
plot(x, data, ‘o’);
hold on;
plot(x, smoothedData2, ‘–‘);
plot(x, smoothedData3, ‘:’);
legend(‘Original Data’, ‘Smoothed Data 2’, ‘Smoothed Data 3’);
title(‘Comparison of Smoothing Methods’);
% Calculate the differences
diff2_3 = smoothedData2(:) – smoothedData3(:);
% Display the differences
disp(‘Difference between smoothedData2 and smoothedData3:’);
disp(diff2_3);
As you can see, the graph is similar for both cases, but the values are different.
I also tried to change the method to ‘lowess’, and the differences there are only on the first and last entries, so I’m guessing that the moving window isn’t calculated similarly in both cases (however, I can’t find a difference in the window calculation from the documentation here and here).
To sum up, my two questions are:
Is there a difference in window calculation between smooth and smoothdata for ‘lowess’ method
Apart from this difference, could there be another issue with the calculation of robust weights for example in ‘rlowess’ method.
Thank you! smooth, smoothdata MATLAB Answers — New Questions