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


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

Re: Average the same elements of the list

Started byDaniel <dosadchy@its.jnj.com>
First post2013-05-24 09:24 +0000
Last post2013-05-24 09:24 +0000
Articles 1 — 1 participant

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


Contents

  Re: Average the same elements of the list Daniel <dosadchy@its.jnj.com> - 2013-05-24 09:24 +0000

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

FromDaniel <dosadchy@its.jnj.com>
Date2013-05-24 09:24 +0000
SubjectRe: Average the same elements of the list
Message-ID<knnbko$qpp$1@smc.vnet.net>
data={{{a1,b1,c1},d1},{{a2,b2,c2},d2}};
{#[[1, 1]], #[[All, 2]] // Mean} & /@ SplitBy[data, First]

output:
{{{a1, b1, c1}, d1}, {{a2, b2, c2}, d2}}

data={{{a1,b1,c1},d1},{{a1,b1,c1},d2}};
{#[[1, 1]], #[[All, 2]] // Mean} & /@ SplitBy[data, First]

output:
{{{a1, b1, c1}, (d1 + d2)/2}}

> 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