Interpolating Missing Data with Noise like Brownian Motion
5 ビュー (過去 30 日間)
古いコメントを表示
Hello folks,
I have a few questions regarding interpolating financial price data set.
I have a set of price points, but their frequency is not high, so I would like to interporlate between these between.
For instance, consider 24 by 2 double price data points where it spans over 24 hours.
Between each hour, I would like to interporlate 15, 30, 45, so total three interporlated points, that way I now have 72 points per day.
However, I would like to insert some noise that follows possibly a geometric brownian motion or random walk to give a flavor of randomness in the data and they are not all linear connected.
What might be the best way to do this?
I have the basic codes so far of importing the data and converting to 24 by 2 double format:
file= "pricedata.xlsx";
Tab =readtable(file);
T=table2array(Tab);
Any suggestions?
Thanks in advance!
0 件のコメント
採用された回答
Bruno Luong
2022 年 9 月 2 日
"What might be the best way to do this?'"
Interpolation THEN
adding noise.
There is no reason to mix the noise generation with interpolation step.
9 件のコメント
Bruno Luong
2022 年 9 月 8 日
編集済み: Bruno Luong
2022 年 9 月 8 日
Because I read this:
"For instance, consider 24 by 2 double price data points where it spans over 24 hours.
...
that way I now have 72 points per day."
You start with 24 data per day and want to end up with 72. 72/24 is 3. But I might miss understanding what you wrote.
その他の回答 (1 件)
Image Analyst
2022 年 9 月 2 日
Try this:
rows = 24;
prices = round(100*rand(rows, 2), 2) % [Beginning of day, end of day]
% Scan down getting prices.
% Allocate 72 points per day, including the start and end.
interpPrices = zeros(rows, 72);
for row = 1 : rows
% Add up to +/- 2 unit of noise.
noise = 2 * rand(1, 72);
interpPrices(row, :) = round(linspace(prices(row, 1), prices(row, 2), 72) + noise, 2);
end
3 件のコメント
Image Analyst
2022 年 9 月 2 日
Yes. prices is the opening and closing prices for the day. You said you already have this. Then you said you wanted to go between those two values with 70 interpolated values that had a bit of noise added to them, for a total of 72 prices per day. Each row of interpPrices is a day, and there are 72 prices at various times thoughout that day.
参考
カテゴリ
Help Center および File Exchange で Descriptive Statistics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!