-1

我的通道测量值> 20,000,必须划分为离散级别,如在我的情况下K = 8,并且必须映射到具有状态的通道测量。我必须在 Matlab 中为此找到状态转移概率矩阵。

我的问题是,我需要知道如何将这些值划分为 8 个状态,并在 Matlab 中找到这 8 个状态的状态转移概率矩阵。

4

1 回答 1

1

这是一个虚构的例子:

%# some random vector (load your data here instead)
x = randn(1000,1);

%# discretization/quantization into 8 levels
edges = linspace(min(x),max(x),8+1);
[counts,bins] = histc(x, edges);

%# fix last level of histc output
last = numel(counts);
bins(bins==last) = last - 1;
counts(last-1) = counts(last-1) + counts(last);
counts(last) = [];

%# show histogram
bar(edges(1:end-1), counts, 'histc')

%# transition matrix
trans = full(sparse(bins(1:end-1), bins(2:end), 1));
trans = bsxfun(@rdivide, trans, sum(trans,2));

需要注意的几点:

  • 离散化只需将整个数据范围划分为 8 个 bin 即可。这是使用histc. 请注意,由于函数的工作方式,我们必须结合最后两个计数并相应地修复 bin。

  • 转移矩阵是通过首先使用函数的一个鲜为人知的调用形式计算共现来计算的sparseaccumarray也可以使用。然后对计数矩阵进行归一化以获得总和为 1 的概率。

  • 您提到您的 MC 模型应该只允许相邻状态之间的转换(1 到 2 或 8 到 7,但不能在 2 和 5 之间)。我没有强制执行这个事实,因为这应该是数据本身的属性,这在这个随机数据示例中不适用。

于 2013-05-03T19:22:17.857 回答