0

I have a code like this:

for i_iter in range(0,max_iter):
    for j_now in range(0,400):
         V[j_now] = np.max(Matrix400_400[:,j_now] + beta * V_old)
    V_old = deepcopy(V)

and I would like to save the indices of the maximizers w.r.t Matrix400_400[:,j_now] in a vector called index. In Matlab this would just work like this:

[V(j_now), index(j_now)] = max(Matrix400_400(:,j_now) + beta*V_old')

But I need do know how this works in python...

Would be great if sb. could help me!

Cheers, Tobias

  • What is i_iter doing? Aren't you repeating max_iter times the loop on j (with no difference between the repetitions since V_old is created only after the loop)? – Mathieu Feb 26 '18 at 15:34
  • i_iter is repeating the first loop max_iter times. This is effective since V_old changes after each j_now loop is over and V changes again because the changed V_old is in the max argument. – econstud12345 Feb 26 '18 at 15:49
  • Right, my bad, I've looked at it a bit fast. I'll check tommorow for your first issue. – Mathieu Feb 26 '18 at 16:44
  • Thanks, Mathieu! Would be great to hear from you again! – econstud12345 Feb 26 '18 at 18:44

0 Answers0