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: Count Function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65556] Re: Count Function
  • From: "Ray Koopman" <koopman at sfu.ca>
  • Date: Fri, 7 Apr 2006 06:14:37 -0400 (EDT)
  • References: <e1091t$ljd$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Gregory Lypny wrote:
> 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

My earlier post omitted the really fast one.

In[1]:= x = Table[Random[Integer,99],{1*^6}];
        Timing@Count[x, x_/;x>14]
        Timing@Length@Select[x,#>14&]
        Timing[SparseArray[Boole@Positive[x-14]] /.
               SparseArray[_, _, _, p_] :> Length@p[[2, 2]]]
        Timing[SparseArray[UnitStep[x-15]] /.
               SparseArray[_, _, _, p_] :> Length@p[[2, 2]]]
Out[2]= {2.17 Second,850268}
Out[3]= {2.17 Second,850268}
Out[4]= {1.1 Second,850268}
Out[5]= {0.09 Second,850268}


  • Prev by Date: Mathematica for Mathematics Education
  • Next by Date: Re: Re: Count Function
  • Previous by thread: Re: Count Function
  • Next by thread: Filtering Strings