How do we interpolate a data set with noise?
43 views (last 30 days)
Show older comments
Tatte Berklee
on 30 Jul 2022
Commented: Tatte Berklee
on 31 Jul 2022
Hello folks,
I am given an 1-D data set representing the daily prices of gold.
I have looked at the 1-D data interpolation that is nicely written by MathWorks: https://www.mathworks.com/help/matlab/ref/interp1.html
Because gold is traded intraday, an hourly data set would better capture this noise than a daily data set, and a 30-minute data would better capture it than the hourly data set ,and so on.
My objective is to interporlate the daily price data with some noise such as a Brownian noise.
Ultimately, I would like to collect these noise-incorporated points as a reasonably good interporlated data and run some other experiments on it.
Any comments or suggestions would be appreciated.
Thanks!
0 Comments
Accepted Answer
John D'Errico
on 30 Jul 2022
Um, you generally don't want to interpolate noisy data! That is just a good way to amplify the noise. I did show many years ago, that the best way to interpolate noisy data is probably simple linear interpolation, thus connect the dots. Even better in that respect is just nearest neighbor interpolation. Typically higher order methods, such as a spline interpolation can produce a solution that is higher variance at any intermediate point. So you don't want to interpolate noise.
Perhaps better is to first smooth your data. Now you can use tools to interpolate the smoothed response. There are of course many tools you can use to smooth data.
t = 1:100;
Y = sin(t/10) + randn(size(t))/3;
plot(t,Y,'o')
Now, if we interpolate the noisy data, we get noisy crap.
tint = linspace(min(t),max(t),1000);
Yint = interp1(t,Y,tint,'spline');
plot(t,Y,'ro',tint,Yint,'r-')
plot(t,smooth(Y),'o')
Clearly an interpolation will fare better based on the smoothed result, though when the noise to signal ratio is high enough, we can still get crap.
3 Comments
John D'Errico
on 30 Jul 2022
Edited: John D'Errico
on 31 Jul 2022
Huh? Why in the name of god and little green apples would you do that?
So just use interpolation. A spline will be fine then. And THEN add noise to it. What is the problem? Ok, I still have no clue why you would do that. Yes, I suppose you are probably generating noisy data for an example problem of some sort. But doing it is trivial.
More Answers (0)
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!