Is there a recommended way to take log_sum_exp of log probability values that are stored in a 3 dimensional array? I have also tried with an array of matrices, but had similar problems. Would it be best to use a matrix[N*N,N]?

Thanks

Is there a recommended way to take log_sum_exp of log probability values that are stored in a 3 dimensional array? I have also tried with an array of matrices, but had similar problems. Would it be best to use a matrix[N*N,N]?

Thanks

1 Like

Do you mean to flatten the whole array and compute log_sum_exp of every element in there? If so check out to_array_1d in: https://mc-stan.org/docs/2_18/functions-reference/mixed-operations.html

If you mean to to NxN log_sum_exps, I think the fastest way is to just loop over them.