Borrar filtros
Borrar filtros

Need help in making a Markov Probability Matrix

2 visualizaciones (últimos 30 días)
Ashwin Chettiar
Ashwin Chettiar el 28 de Ag. de 2020
Editada: Ashwin Chettiar el 6 de Sept. de 2020
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

Respuesta aceptada

Pratyush Roy
Pratyush Roy el 31 de Ag. de 2020
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 comentarios
Jeremy Jenkins
Jeremy Jenkins el 5 de Sept. de 2020
Hi Ashwin, I was wondering how you varied your method to account for the specific probabilities?
Ashwin Chettiar
Ashwin Chettiar el 6 de Sept. de 2020
Editada: Ashwin Chettiar el 6 de Sept. de 2020
By making a very specific probability matrix using for loops.

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by