creating a specific markov probability matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Kiera Rhowen
am 26 Sep. 2020
Kommentiert: Kiera Rhowen
am 27 Sep. 2020
I am trying to consider a particle located on an 8x8 grid that start at the bottom left (at 1) with 64 being at the top right. It moves upwards or sideways (cannot move diagonally).
So the system has 64 states it can be in but i'm not sure how to construct a 64 by 64 matrix with probabilities for this specific grid.
Script Window:
%Creating a state vector s with 64 different states
s = zeros(1,64);
s(1,1) = 1;
%Creating a blank 64x64 probability matrix P
P = zeros(64,64);
%Use for loops to create a Markov probability Matrix.
for i=1:64
for j=1:64
P(i,j)=rand;
%I can only think of putting rand which generates numbers from a uniform distrubuion. I am not sure how to alter it to generate a matix specific to my 8x8 grid.
end
% making the sum for rows = to 1
P(i,:) = P(i,:)/sum(P(i,:));
0 Kommentare
Akzeptierte Antwort
David Hill
am 26 Sep. 2020
If you use linear indexing (iaw Matlab), then the bottom left vertix of your graph is 8 and the top right vertix is 57. Then the probability matrix should be:
a=zeros(64);
for k=2:56
a(k,[k-1,k+8])=.5;
end
for k=58:64
a(k,k-1)=1;
end
for k=9:8:49
a(k,k-1)=0;
a(k,k+8)=1;
end
a(1,9)=1;
3 Kommentare
David Hill
am 26 Sep. 2020
Going from the top left to the bottom right is the same thing mathematically. That would align with the linear indexing of the matrix (1 to 64).
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Markov Chain Models finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!