Re: Integer Length Count
- To: mathgroup at smc.vnet.net
- Subject: [mg128762] Re: Integer Length Count
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Sat, 24 Nov 2012 02:26:06 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
On 11/23/12 at 3:28 AM, sylviehobbs at comcast.net wrote: >I use a function in SAS that takes, in my case, a billion different >integers of varying length and counts the frequency of the length of >each integer by converting the digits in the integers into alpha >characters and counting the frequency of the right most position of >the alpha character. >Meanwhile, let me know any recommendations you have on a Mathematica >function that parallels the SAS Function. To count the number of digits in an integer (base 10) In[3]:= a = Table[RandomInteger[10^n], {n, 5}] Out[3]= {2,22,96,7194,38207} In[4]:= Length[IntegerDigits@#] & /@ a Out[4]= {1,2,2,4,5} To get the frequency of any list of items In[5]:= Tally[RandomInteger[10, 10000]] Out[5]= {{7, 966}, {1, 920}, {3, 918}, {9, 937}, {0, 864}, {5, 918}, {6, 910}, {10, 890}, {4, 892}, {8, 924}, {2, 861}}