|
|
Re: Integer Length Count
Posted:
Nov 24, 2012 2:43 AM
|
|
On 11/23/12 at 3:28 AM, sylviehobbs@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}}
|
|