Re: averaging sublists of different lengths

• To: mathgroup at smc.vnet.net
• Subject: [mg75526] Re: averaging sublists of different lengths
• From: dimitris <dimmechan at yahoo.com>
• Date: Fri, 4 May 2007 04:12:57 -0400 (EDT)
• References: <f19fql\$4q7\$1@smc.vnet.net><f1c55e\$har\$1@smc.vnet.net>

```I didn't understand what you have asked.

So you can ignore my response.

=CF/=C7 dimitris =DD=E3=F1=E1=F8=E5:
> In[151]:=
> lst = {{70, 66, 64, 68, 64, 56, 68, 78, 62, 68, 84}, {70, 64, 64, 56,
> 66, 56, 62, 64, 66, 88, 54, 72},
>     {58, 54, 54, 60, 72, 70, 62, 68, 74, 76, 70}, {66, 56, 60, 64, 56,
> 62, 68, 58, 58, 58, 68, 76, 62, 76, 66, 64, 88, 56},
>     {56, 64, 72, 72, 70, 62, 76, 76, 76, 76, 86, 80, 100}, {60, 60,
> 70, 68, 60, 60, 50, 56, 60, 70, 62, 68, 88, 84, 82},
>     {54, 66, 72, 62, 70, 66, 70, 56}, {60, 60, 60, 62, 74, 80, 70},
> {54, 62, 64, 72, 76, 74}, {66, 74, 70, 80, 54, 54, 64},
>     {72, 66, 60, 52, 52, 66, 66, 58, 60, 66}, {3}, {0, 0}};
>
> In[142]:=
> Mean /@ lst
> Out[142]=
> {68, 391/6, 718/11, 581/9, 966/13, 998/15, 129/2, 466/7, 67, 66,
> 309/5, 3, 0}
>
> In[144]:=
> (Tr[#1]/Length[#1] & ) /@ lst
> Out[144]=
> {68, 391/6, 718/11, 581/9, 966/13, 998/15, 129/2, 466/7, 67, 66,
> 309/5, 3, 0}
>
> In[145]:=
> (Total[#1]/Length[#1] & ) /@ lst
> Out[145]=
> {68, 391/6, 718/11, 581/9, 966/13, 998/15, 129/2, 466/7, 67, 66,
> 309/5, 3, 0}
>
> In[146]:=
> (Plus @@ #1/Length[#1] & ) /@ lst
> Out[146]=
> {68, 391/6, 718/11, 581/9, 966/13, 998/15, 129/2, 466/7, 67, 66,
> 309/5, 3, 0}
>
> In[148]:=
> ((#1 /. {x_, y___} -> x + y)/Length[#1] & ) /@ lst
> Out[148]=
> {68, 391/6, 718/11, 581/9, 966/13, 998/15, 129/2, 466/7, 67, 66,
> 309/5, 3, 0}
>
> ???
>
> Dimitris
>
> =CF/=C7 dantimatter =DD=E3=F1=E1=F8=E5:
> > Hello all,
> >
> > I have a list of lists like this:
> >
> > {{70, 66, 64, 68, 64, 56, 68, 78, 62, 68, 84}, {70, 64, 64, 56, 66,
> > 56, 62,
> >     64, 66, 88, 54, 72}, {58, 54, 54, 60, 72, 70, 62, 68, 74, 76, 70},
> > {66,
> >     56, 60, 64, 56, 62, 68, 58, 58, 58, 68, 76, 62, 76, 66, 64, 88,
> > 56}, {56,
> >     64, 72, 72, 70, 62, 76, 76, 76, 76, 86, 80, 100}, {60, 60, 70, 68,
> > 60, 60,
> >      50, 56, 60, 70, 62, 68, 88, 84, 82}, {54, 66, 72, 62, 70, 66,
> > 70,
> >     56}, {60, 60, 60, 62, 74, 80, 70}, {54, 62, 64, 72, 76, 74}, {66,
> > 74, 70,
> >     80, 54, 54, 64}, {72, 66, 60, 52, 52, 66, 66, 58, 60, 66}}
> >
> > What I'd really like is the average all the 1st values, 2nd values,
> > etc, but I'm having trouble figuring out how to deal with the fact
> > that the lists are not all the same length.   Is there a way to drop
> > the sublists as they run out of points to add to the average, i.e. if
> > I want the average of all the nth values, but Length[shortSublist] <
> > n, can I somehow drop shortSublist and then calculate the average from
> > the other sublists?
> >
> > Also, the Mean[] function requires more than one data point, but I'd
> > still like to extract out the values for which there is only one data
> > point.  Is there a way to do this?
> >
> > Thanks!
> > dan

```

• Prev by Date: Re: Re: MathPlayer???
• Next by Date: Re: Gauss-Kronrod algorithm
• Previous by thread: Re: averaging sublists of different lengths
• Next by thread: Running a loop for Maximizing problem