【问题标题】:Time series in Finite State Space Markov chain有限状态空间马尔可夫链中的时间序列
【发布时间】:2013-05-13 14:31:55
【问题描述】:

我有状态 K=8 的状态转移概率矩阵,

反式 =

0.9245    0.0755         0         0         0         0         0         0
0.0176    0.9399    0.0425         0         0         0         0         0
     0    0.0290    0.9263    0.0447         0         0         0         0
     0         0    0.0465    0.9228    0.0307         0         0         0
     0         0         0    0.0731    0.8979    0.0290         0         0
     0         0         0         0    0.0907    0.8857    0.0236         0
     0         0         0         0         0    0.1080    0.8750    0.0170
     0         0         0         0         0         0    0.1250    0.8750

我需要使用 Matlab 从转换矩阵生成时间向量/时间序列。谁能建议我如何从 Matlab 中的状态转移概率矩阵生成时间序列。

【问题讨论】:

  • 下面的解决方案有效吗?
  • @HarshalPandya 我已经有了你给出的代码,但不幸的是这对我的情况不起作用。我的问题是我需要从转换矩阵生成时间序列向量。在这里我找不到时间序列向量。
  • 如果我错了,请纠正我,但不是时间序列,只是给定转换概率和初始状态的状态连续样本的向量。如果是这样,那么在下面的代码中,设置 T=100 将为您提供链中长度为 100 的向量,这将是您的时间序列。
  • @HarshalPandya 我有一个问题要问你,我已经按照你的说法生成了时间序列,但我需要知道如何从这个时间序列中生成概率密度函数?非常感谢您的帮助...

标签: matlab time-series markov-chains


【解决方案1】:

如果通过生成您的意思是来自转换矩阵的样本,这应该可以工作:

function [chain,state] = simulate_markov(x,P,pi0,T); 
%% x = the quantity corresponding to each state, typical element x(i) 
%% P = Markov transition matrix, typical element p(i,j) i,j=1,...n 
%% pi0 = probability distribution over initial state 
%% T = number of periods to simulate 
%% 
%% chain = sequence of realizations from the simulation 
%% Modification of progam by L&S. 
n = length(x); %% what is the size of the state vector? 
E = rand(T,1); %% T-vector of draws from independent uniform [0,1] 
cumsumP = P*triu(ones(size(P))); 
 %% creates a matrix whose rows are the cumulative sums of 
 %% the rows of P 
%%%%% SET INITIAL STATE USING pi0 
E0 = rand(1,1); 
ppi0 = [0,cumsum(pi0)]; 
s0 = ((E0<=ppi0(2:n+1)).*(E0>ppi0(1:n)))'; 
s = s0; 
%%%%% ITERATE ON THE CHAIN 
for t=1:T, 
 state(:,t) = s; 
 ppi = [0,s'*cumsumP]; 
 s = ((E(t)<=ppi(2:n+1)).*(E(t)>ppi(1:n)))'; 
end 
chain = x'*state;

来源:http://www-scf.usc.edu/~ngarnold/Markov%20Chains%20Notes.pdf

【讨论】:

    猜你喜欢
    • 2015-07-12
    • 2011-06-20
    • 1970-01-01
    • 2017-06-21
    • 1970-01-01
    • 2017-03-18
    • 2017-03-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多