Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #14582 > unrolled thread

Re: Average the same elements of the list

Started byTomas Garza <tgarza10@msn.com>
First post2013-05-23 07:51 +0000
Last post2013-05-23 07:51 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Average the same elements of the list Tomas Garza <tgarza10@msn.com> - 2013-05-23 07:51 +0000

#14582 — Re: Average the same elements of the list

FromTomas Garza <tgarza10@msn.com>
Date2013-05-23 07:51 +0000
SubjectRe: Average the same elements of the list
Message-ID<knkhpi$icr$1@smc.vnet.net>
Elegance is often a matter of individual taste (it lies in the eyes of the 
beholder?), but a possible way is
datanew:=If[data[[1,1]]==data[[2,1]],{data[[1,1]],Mean[{data[[1,2]],data[[2,2]]}]},data]
data={{{1,2,3},4},{{1,2,3},5}}{{{1,2,3},4},{{1,2,3},5}}
datanew{{1,2,3},9/2}
data={{{1,1,3},4},{{1,2,3},5}}{{{1,1,3},4},{{1,2,3},5}}
datanew{{{1,1,3},4},{{1,2,3},5}}
-Tomas
> From: bipsich101@gmail.com
> Subject: Average the same elements of the list
> To: mathgroup@smc.vnet.net
> Date: Wed, 22 May 2013 02:18:09 -0400
>
> Hello,
> I have list which is something like
> data={
> {{a1,b1,c1},d1},{{a2,b2,c2},d2}}
> I would like to get new list which gets average of the second elements if the first elements in the sublists are all the same.
> Namely if a1=a2,b1=b2,c1=c2
> new list would look like
> datanew={{a1,b1,c1},Mean[{d1,d2}]
> Is there an elegant way to do this ?
> Thanks!
>
 	

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web