Re: Median element by element

Jerome Kieffer <[email protected]>
Newsgroups gmane.comp.python.scientific.user
Organization ESRF
Message-ID <[email protected]>
On Mon, 23 Apr 2018 10:08:03 +0200
Paolo Zaffino <[email protected]> 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
_______________________________________________
SciPy-User mailing list
[email protected]
https://mail.python.org/mailman/listinfo/scipy-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.