Matlab的:帮助实施量化时间序列 [英] Matlab: Help in implementing quantized time series

查看:144
本文介绍了Matlab的:帮助实施量化时间序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有实施这一code麻烦,由于变量 s_k 是合乎逻辑的0/1。以什么方式我可以实现这个说法?

s_k 是一个随机序列 0/1 使用兰特产生() 和量化的输出兰特()其平均值如下。在此之后,我不知道如何实现。请帮助。

  N = 1000;
    输入= randn(N);    S =(输入&GT = 0.5); %转换为逻辑0/1;

更新

  N = 3;
TMAX = 5;
Y(1)= 0.1;
对于i = 1:TMAX + N-1%//这里更改
        Y(I + 1)= 4 * Y(I)*(1-Y(I));用于生成输入自回归模型%非线性模型
    结束
 S =(Y> = 0.5);
的ind = bsxfun(@plus,(0:TMAX),(0:N-1)');
X =总和(。秒(IND + 1)*(2 ^( - 的ind + N + 1))); %这个转换的输出应该是实数顺序1%自回归模型
Z(1)= 0;
对于j = 2:N
    Z(j)条= 0.195 * Z(J-1)+ X(J);
结束


解决方案

您已经生成的随机逻辑序列,这是伟大的。你还需要知道 N ,这是点的总数达到一次性收集,以及时间值 T 。因为这是一个离散的总结,我将承担 T 的值是离散的。你需要做的首先是生成一个滑动窗口矩阵。这个矩阵再$ P $的每列psents设定的时间值的为输出 T 的每个值。这可以很容易地与 bsxfun 。假设 TMAX 0 的起始时间和邻里大小 N <的最大时间/ code>(如在你的公式),我们可以做的:

  IND = bsxfun(@plus,(0:TMAX),(0:N-1));

例如,假设 Tmax为5 N = 3 ,我们得到:

  IND =     0 1 2 3 4 5
     1 2 3 4 5 6
     2 3 4 5 6 7

每个柱重新presents,我们要计算在输出和列的每一行一次显示了我们想计算所需输出时间值的列表。

最后,计算输出 X ,你只需把你的 s_k 载体,使之成为列向量,使用 IND 来访问到它,做一个逐点乘用 2 ^( - K + N + 1)用我们从 IND ,并沿行总和替换 K 。所以:

  S =兰特(MAX(IND(:))+ 1,1)&GT; = 0.5;
X =总和(。秒(IND + 1)*(2 ^( - 的ind + N + 1)));

第一条语句生成一个随机矢量,只要我们有最大的时间价值。一旦我们有了这个,我们使用 IND 索引到这个随机向量,使我们能够产生的滑动窗口逻辑值。我们需要通过1作为MATLAB从1开始的索引来抵消这一点。

I am having trouble implementing this code due to the variable s_k being logical 0/1. In what way can I implement this statement?

s_k is a random sequence of 0/1 generated using a rand() and quantizing the output of rand() by its mean given below. After this, I don't know how to implement. Please help.

 N =1000;
    input = randn(N);

    s = (input>=0.5); %converting into logical 0/1;

UPDATE

N = 3;
tmax = 5;
y(1) = 0.1;
for i =1 : tmax+N-1 %// Change here
        y(i+1) = 4*y(i)*(1-y(i));  %nonlinear model for generating the input to Autoregressive model
    end
 s = (y>=0.5);
ind = bsxfun(@plus, (0:tmax), (0:N-1).');
x = sum(s(ind+1).*(2.^(-ind+N+1)));  % The output of this conversion should be real numbers

% Autoregressive model of order 1
z(1) =0;
for j =2 : N
    z(j) =  0.195 *z(j-1) + x(j);
end

解决方案

You've generated the random logical sequence, which is great. You also need to know N, which is the total number of points to collect at one time, as well as a list of time values t. Because this is a discrete summation, I'm going to assume the values of t are discrete. What you need to do first is generate a sliding window matrix. Each column of this matrix represents a set of time values for each value of t for the output. This can easily be achieved with bsxfun. Assuming a maximum time of tmax, a starting time of 0 and a neighbourhood size N (like in your equation), we can do:

ind = bsxfun(@plus, (0:tmax), (0:N-1).');

For example, assuming tmax = 5 and N = 3, we get:

ind =

     0     1     2     3     4     5
     1     2     3     4     5     6
     2     3     4     5     6     7

Each column represents a time that we want to calculate the output at and every row in a column shows a list of time values we want to calculate for the desired output.

Finally, to calculate the output x, you simply take your s_k vector, make it a column vector, use ind to access into it, do a point-by-point multiplication with 2^(-k+N+1) by substituting k with what we got from ind, and sum along the rows. So:

s = rand(max(ind(:))+1, 1) >= 0.5;
x = sum(s(ind+1).*(2.^(-ind+N+1)));

The first statement generates a random vector that is as long as the maximum time value that we have. Once we have this, we use ind to index into this random vector so that we can generate a sliding window of logical values. We need to offset this by 1 as MATLAB starts indexing at 1.

这篇关于Matlab的:帮助实施量化时间序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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