MathGroup Archive 1999

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

Search the Archive

Re: Counting list elements above/below a given value

  • To: mathgroup at smc.vnet.net
  • Subject: [mg17295] Re: Counting list elements above/below a given value
  • From: tobiasoed at my-dejanews.com
  • Date: Fri, 30 Apr 1999 23:22:27 -0400
  • Organization: Deja News - The Leader in Internet Discussion
  • Sender: owner-wri-mathgroup at wolfram.com

These are my ideas but they don't beat yours...

In[38]:= e=Table[Random[],{i,10000}];

In[39]:= value=.5

Out[39]= 0.5

In[40]:= Timing[Length[Select[Flatten[e], value > #1&]]]

Out[40]= {1.53 Second, 4999}

In[41]:= Timing[ii=0;Scan[If[value>#,ii++]&,e];ii]

Out[41]= {3.08 Second, 4999}

In[42]:= Timing[Count[e,x_ /; value>x]]

Out[42]= {2.14 Second, 4999}

In[43]:= Timing[Count[e,_?((value>#)&)]]

Out[43]= {2.06 Second, 4999}

In[44]:= Timing[Apply[Plus,Map[If[value>#,1,0]&,e]]]

Out[44]= {2.28 Second, 4999}

Tobias

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


  • Prev by Date: Re: Mathematica 3.0 and Visual Basic
  • Next by Date: WITH MATH PROG. OUT THERE DISPLAYS STEP BY STEP SOLUTION BEST?
  • Previous by thread: Re: Counting list elements above/below a given value
  • Next by thread: Re: Counting list elements above/below a given value