Need help in making a Markov Probability Matrix

2 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Markov Chain Models 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by