How to generate 100 sample points of a 3-state Markov chain with initial prob vector and transition probability matrix using inverse transform method on matlab.

P = [0.3 0.1 0.1; 0.3 0.9 0.1; 0.4 0 0.8]; % Transition Matrix
P0 = [0.1 0.9 0]; %initial probability Vector
Then I dont know how to do the rest. Please help me.

 採用された回答

Rick Rosson
Rick Rosson 2015 年 11 月 30 日
編集済み: Rick Rosson 2015 年 11 月 30 日
Here's a start:
P = [0.3 0.1 0.1; 0.3 0.9 0.1; 0.4 0 0.8]; % Transition Matrix
P0 = [0.1 0.9 0]; %initial probability Vector
C0 = cumsum(P0);
M = length(P0);
N = 100;
x = nan(N,1);
x(1) = (M + 1) - sum(rand <= C0);
for k = 2:N
x(k) = ...
end

3 件のコメント

bmp_sq
bmp_sq 2015 年 11 月 30 日
Thank you!
bmp_sq
bmp_sq 2015 年 11 月 30 日
what does nan(N,1) function do btw? Can you explain. I never use matlab before. thanks.
Stephen23
Stephen23 2015 年 11 月 30 日
編集済み: Stephen23 2015 年 11 月 30 日
@jndmwx: then you need to learn to use the documentation. You can search the documentation using any good internet search engine. I just searched for "MATLAB nan", and this is the first result that was returned:
"For example, NaN(3,4) returns a 3-by-4 array of NaN values".

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeParticle & Nuclear Physics についてさらに検索

質問済み:

2015 年 11 月 30 日

編集済み:

2015 年 11 月 30 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by