MathGroup Archive 2006

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

Search the Archive

Re: Re: Speed challenge: Improve on integer frequencies from Count?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67793] Re: [mg67778] Re: Speed challenge: Improve on integer frequencies from Count?
  • From: Sseziwa Mukasa <mukasa at jeol.com>
  • Date: Sat, 8 Jul 2006 04:55:47 -0400 (EDT)
  • References: <e8ir3t$s8o$1@smc.vnet.net> <200607071112.HAA27553@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Here's an implementation using one pass through the data to increment  
the appropriate bin in a histogram:

myFrequencies3[lst_,maxInt_]:=
   Block[{hist=Table[0,{maxInt+1}]},
     hist[[#+1]]++&/@lst;hist]

this is slower than you function, but the compiled version

myFrequencies4=Compile[{{lst,_Integer,1},{
     maxInt,_Integer}},
     Block[{hist=Table[0,{maxInt+1}]},
       hist[[#+1]]++&/@lst;hist]]

is nearly an order of magnitude faster on my machine.

Regards,

Ssezi


  • Prev by Date: Re: Beginner--How to get a positive solution from Solve Command
  • Next by Date: Non Linear fit problem
  • Previous by thread: Re: Speed challenge: Improve on integer frequencies from Count?
  • Next by thread: Hamiltonian circuits