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: [mg91964] Re: eliminate values while caculating Mean[data]
  • From: Szabolcs Horvát <szhorvat at gmail.com>
  • Date: Mon, 15 Sep 2008 03:41:17 -0400 (EDT)
  • Organization: University of Bergen
  • References: <gag2rl$3fq$1@smc.vnet.net>

Pasha Karami 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?
> 

Just filter the data first:

Cases[data, Except[0]] (* will only filter 0, but not 0.0 *)

Select[data, # != 0 &]

data /. 0 -> Sequence[] (* will only filter 0, but not 0.0 *)


  • Prev by Date: Re: eliminate values while caculating Mean[data]
  • Next by Date: Re: Apparent error integrating product of DiracDelta's
  • Previous by thread: Re: eliminate values while caculating Mean[data]
  • Next by thread: Re: eliminate values while caculating Mean[data]