MATLAB Answers

PCHIP and SPline error

3 views (last 30 days)
Grateful for help. I have interpolated some data using spline and pchip. Data shown below. How would I work out the interpolation error for each?
% Flux in 0.5 MJD
t=[58287.15
58288.202
58289.0234
58289.1889
58289.9147
58290.1082
58290.2189
58290.2922
58290.9029
58291.0145
58291.1742
58291.9275
58292.0222
58292.1866
58292.2473
58292.3556
58292.947
58293.0555
58293.2461
58293.2697
58293.9283
58294.168
58294.2042
58294.2153
58294.9032
58295.1518
58295.1978
58295.9173
58296.1643
58296.23
58296.6816
58296.9001
58297.2785
58297.6351
58297.8937
58298.1642
58298.904
58299.1624
58299.1664
58299.245
58299.8931
58300.1576
58300.2022
58300.3249
58300.9133
58301.2077
58301.3227
58301.904
58302.1568
58302.2014
58302.2813
58302.3085
58302.8936
58303.2129
58303.9063
58304.2865
58304.3141
58305.3268
58305.9029
58306.1943
58306.2667
58306.3846
58306.903
58307.2238
58307.9192
58308.3248
58308.8887
58309.9173
58310.9116
58311.3567
58311.9058
58312.3649
58312.9121
58313.2409
58313.3416
58313.9209
58314.9344
58315.9392
58316.167
58316.9031
58317.9546
58318.9173
58321.9361
58322.1578
58322.8874
58323.1569
58323.9013
58324.1762
58324.8934
58325.8885
58326.9282
58327.1782
58327.9357
58328.1801
58328.9395
58329.9399
58330.907
58334.8906
58339.9048
58346.9219
58366.9047]
F= [20644.29232
16398.34428
10834.27862
10064.68066
7634.841052
7027.486177
6649.668571
6234.476611
4998.043136
4773.094139
4353.113592
3933.688807
3861.890894
3861.890894
3654.264678
3620.762178
3302.174353
3271.899836
3095.993213
3124.640086
2721.447746
2551.526011
2551.526011
2504.955413
2141.903991
2008.167804
1989.756811
1814.679779
1717.117443
1717.117443
1670.321226
1639.834428
1481.835518
1523.351063
1523.351063
1468.249968
1415.141933
1376.575387
1363.954868
1339.059886
1187.955028
1155.579955
1155.579955
1134.488244
1073.494936
1025.179705
988.0979539
909.4943386
837.1436744
837.1436744
829.4686951
799.4660025
756.4844408
729.12166
689.9220098
683.5967668
677.329514
652.8298442
629.2163513
589.9293451
589.9293451
595.3878941
553.0953407
538.0219572
486.1832585
460.0446664
451.6479049
404.3896205
327.1899836
303.9484969
290.268561
279.7692638
290.268561
284.9705627
287.6073629
269.6497364
241.434873
210.2809837
204.5502431
188.2781837
176.5224717
144.1451386
118.7955028
122.123713
110.357029
105.3901445
100.6468066
100.6468066
84.48896695
82.94686951
75.64844408
69.63057796
65.28298442
67.7329514
64.68446642
57.91619211
60.08969505
40.43896205
25.04955413
16.24800335
4.043896205];
% Interpolation using Spline
tI=[58287.5
58288
58288.5
58289
58289.5
58290
58290.5
58291
58291.5
58292
58292.5
58293
58293.5
58294
58294.5
58295
58295.5
58296
58296.5
58297
58297.5
58298
58298.5
58299
58299.5
58300
58300.5
58301
58301.5
58302
58302.5
58303
58303.5
58304
58304.5
58305
58305.5
58306
58306.5
58307
58307.5
58308
58308.5
58309
58309.5
58310
58310.5
58311
58311.5
58312
58312.5
58313
58313.5
58314
58314.5
58315
58315.5
58316
58316.5
58317
58317.5
58318
58318.5
58319
58319.5
58320
58320.5
58321
58321.5
58322
58322.5
58323
58323.5
58324
58324.5
58325
58325.5
58326
58326.5
58327
58327.5
58328
];
FI = spline(t,F, tI);
% Interpolation using PCHIP
FI_pc=pchip(t,F, tI);

  0 Comments

Sign in to comment.

Accepted Answer

Kiran Felix Robert
Kiran Felix Robert on 28 Aug 2020
Hi Robbie,
We don’t have statistical error bounds for interpolation, as the interpolation functions takes in the query points and fits a curve. This answer explains the concept in detail.
Whereas, when you use the interp function which uses a low-pass filter for interpolation, that will also change the y-value at the sample points. This gives rise to a difference which we can quantify as the interpolation error. You can refer to this answer which gives a way to quantify the error vector.
So when you say interpolation error, I assume that you are trying to calculate the error between the interpolated values of spline interpolation and PCHIP interpolation, if that is the case you can calculate that as shown below,
error = Fl - Fl_pc;
Kiran Felix Robert

  2 Comments

Robbie Baillie
Robbie Baillie on 31 Aug 2020
Thank you for your help.
Robbie Baillie
Robbie Baillie on 31 Aug 2020
Just as a query - if I was to interpolate to get the data points I want and the empirical data points that I interpolated - then matched the empirical data points to the same interpolated data points - is that a valid way of working out the uncertainty (rather than error).
Hope this makes sense.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!