⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 volaplot.m

📁 Modeling and Forecasting Electricity Loads and Prices: A Statistical Approach" by Rafa&#322 Weron, p
💻 M
字号:
function v=volaplot(x,n)
%VOLAPLOT Volatility plot.
%   VOLAPLOT(X,N) plots volatility of times series X averaged over N 
%   periods (eg. days).
%   V=VOLAPLOT(X,N) instead of plotting returns the volatility series.

%   Written by Rafal Weron (2000.12.15)
%   Copyright (c) 2000-2006 by Rafal Weron

x = x(:);
Lx = length(x);
k = floor(n/2);

if n/2 == k,
    if nargout == 0,
        disp(['Volatility calculated over ' num2str(n-1) ' periods']);
    end
    n = n-1;
    k = floor(n/2);
end;

xx = [ones(k,1)'*x(1) x' ones(k,1)'*x(Lx)]';

v = zeros(Lx,1);
for i = 1:Lx,
    v(i) = std(xx(i:i+n-1));
end;

if nargout == 0,
    plot(1:Lx,x,1:Lx,v)
    s = [num2str(n) '-day volatility'];
    legend('Times series',s)
end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -