Cubic smoothing spline error measure weights

조회 수: 3 (최근 30일)
MJ
MJ 2021년 7월 30일
답변: Abhaya 2024년 12월 19일
How exactly does the error measure weights work in csaps cubic smoothing spline function?
What does it mean by error measure weights? I have read the documentation through but it is unclear to me.
I would like to construct a smoothing spline based on weights of each spline, meaning that ones with greater weight value should be considered more for the spline. (i.e. something with a weight of 0.1 would be considered more of an outlier compared to something with a weight of 0.9) Is this how it works in csaps?
It would be great if there was some kind of mathematical explanation of how csaps works.

답변 (1개)

Abhaya
Abhaya 2024년 12월 19일
Hi MJ,
The MATLAB ‘csaps’ function tries to minimize the error function, which depends on error values and smoothing measure.
In the context of csaps, the error measure weights w_i control how much each data point contributes to the fitting error. A higher weight for a data point means that point has more influence on the spline, while a lower weight means the point has less influence.
The default value for the weight vector w in the error measure is ones(size(x)).
Below is an example to help illustrate how weights affect the spline fitting:
x = [1, 2, 3, 4, 5];
y = [2, 2, 3, 4, 1];
w1 = [1,1,0.5,0.1,1];
w2 = [1,1,0.5,1,1];
lambda = 0.8; %smoothing factor
xx=linspace(1,5,100);
pp1 = csaps(x,y,lambda,xx,w1);
pp2 = csaps(x,y,lambda,xx,w2);
figure;
plot(x, y, 'ko', 'MarkerFaceColor', 'k');
hold on;
plot(linspace(1,5,100),pp1, 'b-', 'LineWidth', 2);
plot(linspace(1,5,100),pp2, 'r-', 'LineWidth', 2);
ylim([1,6])
legend('Data points','Spline with reduced weight at x=4','Spline with weight at x=4 set to 1');
For more information on MATLAB ‘csaps’ function please refer to the MATLAB documentation linked below.
Hope it resolves your query.

카테고리

Help CenterFile Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by