Skip to main content
3 events
when toggle format what by license comment
Jun 28, 2022 at 1:10 comment added xzczd @EstabanW For your specific case tst3 = Transpose[Transpose[d, {3, 1, 2}] - Mean@d, {2, 3, 1}]; // AbsoluteTiming should be even faster :) .
Jun 27, 2022 at 18:34 comment added EstabanW the Threaded functionality is a lot more intuitive with more complex array shapes - I was working with an array d, dims {n,2,3} (n large), this construction Transpose[MapThread[Function[{d, m}, # - m & /@ d], {Transpose[d, {2, 3, 1}], Mean /@Transpose[d, {2, 3, 1}]}], {3, 1, 2}] reduced to d - Threaded[ArrayReduce[Mean, d, 1]] (Threaded plays well with ArrayReduce). It was a bit slower (2x) but far easier to read and write.
Jun 27, 2022 at 6:17 history answered xzczd CC BY-SA 4.0