Need help in making a Markov Probability Matrix

2 ビュー (過去 30 日間)
Ashwin Chettiar
Ashwin Chettiar 2020 年 8 月 28 日
編集済み: Ashwin Chettiar 2020 年 9 月 6 日
Consider a new particle, located on an 8 × 8 grid. The particle begins in the bottom left-hand corner, which is given the label square 1. The particle can move horizontally or vertically randomly. This system has 64 different states, corresponding to the particle being in each of the 64 squares. Use for loops in Matlab to efficiently create the Markov transition matrix (you are not expected to create a 64 × 64 matrix by hand!).
So far, I have been able to create the state vector and a blank probability matrix. The problem that I am having is that I do not understand how to use for loops to generate a Markov matrix with the constraints that I have been given.
My code so far:
%Create a state vector s with 64 different states
s = zeros(1,64);
s(1,1) = 1;
%Create a blank 64x64 probability matrix P
P = zeros(64,64);
%Use for loops to create the Markov Probability Matrix

採用された回答

Pratyush Roy
Pratyush Roy 2020 年 8 月 31 日
Assuming random values for the Markov probability matrix, the following snippet might be helpful for defining a Markov Probability Matrix using for loops:
%Create a state vector s with 64 different states
s = zeros(1,64);
s(1,1) = 1;
%Create a blank 64x64 probability matrix P
P = zeros(64,64);
%Use for loops to create the Markov probability Matrix.
for i=1:64
for j=1:64
P(i,j)=rand; %Generates a random number from a uniform distribution in range(0,1)
end
P(i,:) = P(i,:)/sum(P(i,:)); % This forces the sum across columns to be unity
end
You can also refer to the following documentation for defining a Markov Probability Matrix without using for loops:
  3 件のコメント
Jeremy Jenkins
Jeremy Jenkins 2020 年 9 月 5 日
Hi Ashwin, I was wondering how you varied your method to account for the specific probabilities?
Ashwin Chettiar
Ashwin Chettiar 2020 年 9 月 6 日
編集済み: Ashwin Chettiar 2020 年 9 月 6 日
By making a very specific probability matrix using for loops.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMarkov Chain Models についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by