MathGroup Archive 2001

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

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg26961] Re: [mg26923] Any better way for finding frequencies of list entries?
  • From: "Hermann Meier" <hmeier at webshuttle.ch>
  • Date: Tue, 30 Jan 2001 03:38:14 -0500 (EST)
  • Organization: EUnet AG, Switzerland. A KPNQwest Company.
  • References: <94vs1v$o9t@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

One can also rely on built-in functions:

DigitCount[FromDigits[RealDigits[N[Pi,57]][[1]]]]

{5, 6, 9, 4, 6, 4, 5, 6, 9, 3}

This is the frequency of the numbers 1,2 ... 0 in N[Pi,57]


With best regards
Hermann Meier


> In a message dated 2001/1/26 11:56:30 PM, doud25 at caramail.com writes:
>
> >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?
>



  • Prev by Date: Queries: notebook, matrices
  • Next by Date: Re: Any better way for finding frequencies of list entries?
  • Previous by thread: Re: Any better way for finding frequencies of list entries?
  • Next by thread: Re: Any better way for finding frequencies of list entries?