Displaying 1 result from an estimated 1 matches for "argmax_l".
Did you mean:
argmax
2004 Mar 31
1
extracting values from a 3d array using a matrix from indices
Suppose I have A, an n x m matrix, each element is an integer (an
index).
I also have B, an n x l x m array. I need C, where
C[n,m] = B[n, A[n, m], m]
I am currently using loops, what would be the "R way" to do this?
Another question: let
A[n, m] <- argmax_l B[n, l, m]
what would be the nicest way of doing this? Currently I am using
max.col and a single loop, going though the n's.
Background: I solving a discrete-space dynamic programming problem, A
is the optimal policy, C is the value function. The structure of the
problem allows me to use ma...