       Re: Means

• To: mathgroup at smc.vnet.net
• Subject: [mg73924] Re: Means
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Sat, 3 Mar 2007 01:04:14 -0500 (EST)
• Organization: The Open University, Milton Keynes, UK
• References: <es9295\$3na\$1@smc.vnet.net>

```JGBoone at gmail.com wrote:
> I was wondering if anyone knew how to take the mean of only half of a
> paired order. I have a table of 3000 pairs and want to take the
> average of the last half of the last number in the pair. I do this by
> N[Mean[Map[Last, list]]] is there any way to map to the last half of
> the list. Thanks

You could use Take with a negative second argument as in the following:

In:=
list = Table[{Random[], Random[Integer, 10]}, {20}]

Out=
{{0.134179, 2}, {0.122422, 8}, {0.540121, 5},
{0.490495, 7}, {0.97891, 4}, {0.458892, 4},
{0.698429, 1}, {0.549347, 6}, {0.214567, 9},
{0.670112, 10}, {0.118525, 2}, {0.754165, 7},
{0.2386, 6}, {0.233337, 1}, {0.838034, 7},
{0.126505, 9}, {0.597379, 8}, {0.469553, 1},
{0.405691, 3}, {0.845892, 0}}

In:=
N[Mean[Last /@ Take[list, -10]]]

Out=
4.4

In:=
N[Mean[Last /@ Take[list, -Length[list]/2]]]

Out=
4.4

Regards,
Jean-Marc

```

• Prev by Date: Re: The Mathematica equivalent of Cons (as in Lisp)?
• Next by Date: Re: Parse results from Solve
• Previous by thread: Re: Means
• Next by thread: Re: Re: Means