MathGroup Archive 2001

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

Search the Archive

Any better way for finding frequencies of list entries?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg26923] Any better way for finding frequencies of list entries?
  • From: Domi <doud25 at caramail.com>
  • Date: Fri, 26 Jan 2001 23:30:01 -0500 (EST)
  • Organization: Wanadoo, l'internet avec France Telecom
  • Sender: owner-wri-mathgroup at wolfram.com

Hello Mathematica experts out there, 

I want to determine the frequencies of the entries in a list of integers

For example, the following piece of code seems to work with Pi: 
pi = Join
    [ {3}, ToExpression[Characters[StringDrop[ToString[N[Pi, 57]], {1, 
2}]]]]
Table[{i, Count[pi, i]}, {i, 0, 9}]

    {{0, 3}, {1, 5}, {2, 6}, {3, 9}, {4, 4}, {5, 6}, {6, 4}, {7, 5},
    {8, 6}, {9,   9}}

Question: Is there a more elegant way to do that?

Regards from Domi.


  • Prev by Date: Re: Q: lefthand/right hand side of equation
  • Next by Date: Multiply 2 Lists together in a certain way
  • Previous by thread: Re: Who can help me? (Instabilty of Evaluation)
  • Next by thread: Re: Any better way for finding frequencies of list entries?