MathGroup Archive 2006

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

Search the Archive

Re: Conditions with Statistical Functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg66131] Re: [mg66091] Conditions with Statistical Functions
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sun, 30 Apr 2006 04:21:54 -0400 (EDT)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com
  • Sensitivity: Normal

conditionalMean[x_List?VectorQ, cond_Function]:=
    Mean[Select[x,cond]];

conditionalMean[x_List, cond_Function]:=
    conditionalMean[#,cond]&/@Transpose[x];

m=Table[Random[Integer,200],{4},{3}]

{{12, 138, 117}, {92, 13, 178}, {147, 131, 123}, {34, 177, 109}}

Mean/@m

{89, 283/3, 401/3, 320/3}

Mean[m]

{285/4, 459/4, 527/4}

conditionalMean[#,(#>100)&]&/@m

{255/2, 178, 401/3, 143}

conditionalMean[m,(#>100)&]

{147, 446/3, 527/4}


Bob Hanlon


---- Gregory Lypny <gregory.lypny at videotron.ca> wrote: 
> Yes, thanks Bob.  But what about a matrix, where Mean operates column- 
> wise?  Is there a compact statement where the mean will be calculated  
> over the values that exceed 100 in each column all in one shot?  What  
> I've been doing is looping Select across the columns using Do and  
> applying Mean on each pass.  I just thought there might be something  
> more efficient, if not more elegant.
> 
> Regards,
> 
> 	Greg
> 
> On Sat, Apr 29, 2006, at 6:53 AM, Bob Hanlon wrote:
> 
> > x={10,20,150,200,250};
> >
> > Mean[Select[x,#>100&]]
> >
> > 200
> >
> >
> > Bob Hanlon
> >
> 


  • Prev by Date: Re: 3D plot with range restricted to non-rectangular region
  • Next by Date: Re: 3D plot with range restricted to non-rectangular region
  • Previous by thread: Re: Conditions with Statistical Functions
  • Next by thread: Calling .exe with Run