MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: eliminate values while caculating Mean[data]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg91972] Re: [mg91946] eliminate values while caculating Mean[data]
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Mon, 15 Sep 2008 03:42:47 -0400 (EDT)
  • Reply-to: hanlonr at cox.net

data = {1, 2, 3, 4, 5, 0, 0, 0};

Mean[DeleteCases[data, 0]]

3

Mean[Cases[data, _?(# != 0 &)]]

3

Mean[Select[data, # != 0 &]]

3

Mean[Complement[data, {0}]]

3

Mean[data /. 0 -> Sequence[]]

3

Mean[Pick[data, Thread[data != 0]]]

3


Bob Hanlon

---- Pasha Karami <karami at geo.uu.nl> wrote: 

=============
Dear all,

An easy question:
I would like to make an average of a data file.I know that we can use
Mean function for this.

However, I want to  eliminate some values from my data.For example if I have

data={1,2,3,4,5,0,0,0}
Mean[data] would be 15/8

I do not want the "zero" values in my Mean function (i.e.I want the mean
value to be 3 in the above example) How can I do this?

Thank you!
Best,
Pasha



--

Bob Hanlon



  • Prev by Date: Re: eliminate values while caculating Mean[data]
  • Next by Date: Re: eliminate values while caculating Mean[data]
  • Previous by thread: Re: eliminate values while caculating Mean[data]
  • Next by thread: Re: eliminate values while caculating Mean[data]