Re: Any better way for finding frequencies of list entries?
- To: mathgroup at smc.vnet.net
- Subject: [mg26951] Re: [mg26923] Any better way for finding frequencies of list entries?
- From: BobHanlon at aol.com
- Date: Sat, 27 Jan 2001 20:00:15 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Needs["Statistics`DataManipulation`"]; Here is a simpler form of your approach and some other methods. Table[{i, Count[ToExpression[Characters[StringDrop[ToString[N[Pi, 57]], {2}]]], i]}, {i, 0, 9}] == Table[{i, Count[RealDigits[N[Pi, 57]][[1]], i]}, {i, 0, 9}] == (({#, 1}& /@ Sort[RealDigits[N[Pi, 57]][[1]]])//.{f___,{x_,k_},{x_,n_}, e___}:>{f,{x,k+n},e}) == Reverse /@ Frequencies[RealDigits[N[Pi, 57]][[1]]] True Bob Hanlon 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?