MathGroup Archive 2001

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

Search the Archive

Re: Any better way for finding frequencies of list entries?


Needs["Statistics`DataManipulation`"]
Off[General::spell, General::spell1]
list = RealDigits[N[Pi, 60]][[1]];
Transpose[{Range[0, 9], CategoryCounts[list, Range[0, 9]]}]

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

-matt






Domi <doud25 at caramail.com> on 01/26/2001 09:30:01 PM

cc:
Subject: [mg26976]  [mg26923] Any better way for finding frequencies of list entries?



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: Any better way for finding frequencies of list entries?
  • Next by Date: Re: i need help
  • Previous by thread: Re: Any better way for finding frequencies of list entries?
  • Next by thread: Re: Re: Any better way for finding frequencies of list entries?