Hi all, if I have n 3D matixes with the same shape, is it possible to obtain a new 3D matrix containing the median values computed element by element across all the n inputs? Of course I could run a series of for cycles, but I definitely prefer a pythonitic way of doing that. Thanks a lot in advance. Paolo
On Mon, 23 Apr 2018 10:08:03 +0200 Paolo Zaffino <p.zaffino@yahoo.it> wrote:
Hi all, if I have n 3D matixes with the same shape, is it possible to obtain a new 3D matrix containing the median values computed element by element across all the n inputs? Of course I could run a series of for cycles, but I definitely prefer a pythonitic way of doing that.
What about allocating a 4D array, copying the n datasets there and perform numpy.median(axis=1/-1). There are 2 options: * unoptimized copy + optimized median along the last axis or * optimized copy + unoptimized median along first axis. The former is probably faster but this may vary depending on your dataset size. Cheers, -- Jérôme Kieffer
participants (2)
-
Jerome Kieffer -
Paolo Zaffino