Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: Re: Count Function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65557] Re: [mg65533] Re: [mg65501] Count Function
  • From: "Carl K. Woll" <carlw at wolfram.com>
  • Date: Fri, 7 Apr 2006 06:14:38 -0400 (EDT)
  • References: <200604061052.GAA19539@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

David Park wrote:
> Greg,
> 
> What about...
> 
> Count[X[[All,14]], x_/;x > -9.]
> 
> David Park
> djmp at earthlink.net
> http://home.earthlink.net/~djmp/ 
> 

For long vectors it might be worthwhile to consider alternate methods. 
For example, counting elements larger than .5 in a random vector of 
length 10^6:

In[1]:=
data = Table[Random[], {10^6}];

In[2]:=
Count[data,x_/;x>.5]//Timing
Total[UnitStep[data-.5]]//Timing

Out[2]=
{1.688 Second,499979}

Out[3]=
{0.062 Second,499979}

Carl Woll
Wolfram Research

> 
> 
> From: Gregory Lypny [mailto:gregory.lypny at videotron.ca]
To: mathgroup at smc.vnet.net
> To: mathgroup at smc.vnet.net
> 
> 
> The syntax will be the death of me.
> 
> Count[X[[All,14]], -9.] will tally how many elements in column 14 of  
> matrix X are equal to -9, but I can't for the life of me figure out  
> how to get how many are greater than -9.  Any hint would be most  
> appreciated.
> 
> 	Greg
> 
> 



  • Prev by Date: Re: Count Function
  • Next by Date: GridBox coming back unevaluated
  • Previous by thread: Re: Count Function
  • Next by thread: Re: Count Function