Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Given a array of lists with the same number of here N = 10 elements:

SuperList = {{5., 4.99667, 4.99335, 4.99002, 4.98669, 4.98337, 4.98004, 4.97671, 4.97338, 4.97006}, {5., 4.99667, 4.99335, 4.99002, 4.98669, 4.98337, 4.98004, 4.97671, 4.97338, 4.97006}, {5., 4.99667, 4.99335, 4.99002, 4.98669, 4.98337, 4.98004, 4.97671, 4.97338, 4.97006}, {5.,4.99667, 4.99335, 4.99002, 4.98669, 4.98337, 4.98004, 4.97671, 4.97338, 4.97006}, {5.1, 5.09667, 5.09335, 5.09002, 5.08669, 5.08337, 5.08004, 5.07671, 5.07338, 5.07006}, {5., 5., 5., 5., 5., 5., 5., 5., 5., 5.}, {5., 5., 5., 5., 5., 5., 5., 5., 5., 5.}, {5., 5., 5., 5., 5., 5., 5., 5., 5., 5.}, {5., 5., 5., 5., 5., 5., 5., 5., 5., 5.}, {5., 4.99667, 4.99335, 4.99002, 4.98669, 4.98337, 4.98004, 4.97671, 4.97338, 4.97006}};

How do I efficiently compute an array, which we'll call "MedianList" of length N where each element in the array is the median or mean of the sublist entries at the same index in the "SuperList"? For example, the first element would be:

MedianList[[1]] = Median[{5., 5., 5., 5., 5.1, 5., 5., 5., 5., 5.}];

The second element would be:

MedianList[[2]] = Median[{4.99667, 4.99667, 4.99667, 4.99667, 5.09667, 5., 5., 5., 5., 4.99667}];

And so forth.

share|improve this question

Doesn't Median[SuperList] do just that?

From the documentation:

${\text{Median}}\left(\left\{\left\{x_1,y_1,\ldots \right\},\left\{x_2,y_2,\ldots \right\},\ldots \right\}\right) \text{ gives } \left\{\text{Median}\left[\left\{x_1,x_2,\ldots \right\}\right],\text{Median}\left[\left\{y_1,y_2,\ldots \right\}\right]\right\} \text{. }$

share|improve this answer
    
You're right, but I don't really like this - from MMA, not you. I would have done Median/@(Transpose@SuperList). Anyone have any insight as to why Median acts like this? – N.J.Evans Oct 27 '15 at 20:51
1  
@N.J.Evans: It's consistent with most of the other statistical functions like Mean or Variance, which all treat a 2d array as a list of multivariate data samples. And if you're working with multivariate data, that is very useful. – nikie Oct 28 '15 at 7:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.