间隔不相等的时间序列的移动平均值 [英] Moving average for time series with not-equal intervls

查看:114
本文介绍了间隔不相等的时间序列的移动平均值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于股票价格的数据集:时间-价格.但是数据点之间的间隔不相等-从1到2分钟.

I have a dataset for price of the ticker on the stock exchange: time - price. But intervals between data points are not equal - from 1 to 2 minutes.

在这种情况下计算移动平均值的最佳实践是什么? 如何在Matlab中制作?

What is the best practice to calculate moving average for such case? How to make it in Matlab?

我倾向于认为,这些点的权重应该取决于自上一个点以来的最后一个时间间隔. Matlab中是否具有使用自定义点权重来计算移动平均值的功能?

I tend to think, that weights of the points should depend on the time interval that was last since previous point. Does we have function in Matlab to calculate moving average with custom weights of the points?

推荐答案

以下是我在上面的评论中提到的幼稚"方法的示例:

Here is an example of the "naive" approach I mentioned in the comments above:

% some data (unequally spaced in time, but monotonically non-decreasing)
t = sort(rand(50,1));
x = cumsum(rand(size(t))-0.5);

% linear interpolatation on equally-spaced intervals
tt = linspace(min(t), max(t), numel(t));
xx = interp1(t, x, tt, 'linear');

% plot two data vectors
plot(t, x, 'b.-', tt, xx, 'r.:')
legend({'original', 'equally-spaced'})

这篇关于间隔不相等的时间序列的移动平均值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆