-1

I'm trying to create a loop for a probability distribution. My initial condition is $p_0 = (1, 0, 0, 0, 0)$, $T$ = [0 1/3 1/3 1/3 0; 1/2 0 1/2 0 0; 1/3 1/3 0 1/3 0; 1/3 0 1/3 0 1/3; 0 0 0 1 0], (T is a five by five matrix)

and I am trying to find the probability distribution for the first 50 steps my using $p_n = p_0*T$ however I keep getting error messages. I'm not good with coding, this is what I have so far:

for n= 1:50;

p(n)= p(n-1)*(T);

end

Any code suggestions?

Sarcanel
  • 3
  • 1

1 Answers1

0

Something like this?

p0 = [1; 0; 0; 0; 0];

T = [0, 1/3, 1/3, 1/3, 0; 1/2, 0, 1/2, 0, 0; 1/3, 1/3, 0, 1/3, 0; 1/3, 0, 1/3, 0, 1/3; 0, 0, 0, 1, 0];

n_steps = 50;

p = p0; for n = 1:n_steps p = T*p; end

mmikkelsen
  • 396
  • 1
  • 15
  • 1
    Notice that the OP uses the convention of a state row vector being right multiplied by the state transition matrix. – hardmath Oct 20 '23 at 16:22