![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1821393/image.png)
Cubic smoothing spline error measure weights
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponses (1)
Abhaya
le 19 Déc 2024
Hi MJ,
The MATLAB ‘csaps’ function tries to minimize the error function, which depends on error values and smoothing measure.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1821393/image.png)
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.
0 commentaires
Voir également
Catégories
En savoir plus sur Splines dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!