Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #12426 > unrolled thread
| Started by | sylviehobbs@comcast.net |
|---|---|
| First post | 2012-11-23 08:30 +0000 |
| Last post | 2012-11-24 07:41 +0000 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Integer Length Count sylviehobbs@comcast.net - 2012-11-23 08:30 +0000
Re: Integer Length Count daniel.lichtblau0@gmail.com - 2012-11-24 07:27 +0000
Re: Integer Length Count Ray Koopman <koopman@sfu.ca> - 2012-11-24 07:28 +0000
Re: Integer Length Count Helen Read <readhpr@gmail.com> - 2012-11-24 07:41 +0000
| From | sylviehobbs@comcast.net |
|---|---|
| Date | 2012-11-23 08:30 +0000 |
| Subject | Integer Length Count |
| Message-ID | <k8nc79$dh1$1@smc.vnet.net> |
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. I am trying to do more and more routine programming in Mathematica and after poking around in documentation for the past 4 hours have yet to find the parallel function in Mathematica for counting the integer frequency length in a big data set. My family wants me to drop everything and put the Turkey in the oven. My cat Sylvester even fell asleep on his back in front of the refrigerator with his little legs up in the air, so he want miss the transfer of the Turkey from the stove to the refrigerator. OH WELL -- IT'S SHOW TIME! Meanwhile, let me know any recommendations you have on a Mathematica function that parallels the SAS Function. Sylvia Hobbs
[toc] | [next] | [standalone]
| From | daniel.lichtblau0@gmail.com |
|---|---|
| Date | 2012-11-24 07:27 +0000 |
| Message-ID | <k8pstl$iqt$1@smc.vnet.net> |
| In reply to | #12426 |
On Friday, November 23, 2012 2:32:54 AM UTC-6, sylvi...@comcast.net wrote:
> I use a function in SAS that takes, in my case, a billion different integ=
ers of varying length and counts the frequency of the length of each intege=
r by converting the digits in the integers into alpha characters and counti=
ng the frequency of the right most position of the alpha character.
>
>
>
>
>
>
>
> I am trying to do more and more routine programming in Mathematica and af=
ter poking around in documentation for the past 4 hours have yet to find th=
e parallel function in Mathematica for counting the integer frequency lengt=
h in a big data set. My family wants me to drop everything and put the Turk=
ey in the oven. My cat Sylvester even fell asleep on his back in front of t=
he refrigerator with his little legs up in the air, so he want miss the tra=
nsfer of the Turkey from the stove to the refrigerator. OH WELL -- IT'S SHO=
W TIME!
>
>
>
>
>
>
>
> Meanwhile, let me know any recommendations you have on a Mathematica func=
tion that parallels the SAS Function.
>
>
>
>
>
>
>
> Sylvia Hobbs
Could take floor of logs base 10 to get the digit counts.
listofintegers =1+10^RandomInteger[{0,12},{100}];
Tally[Map[Floor[Log[10.,#]]&, listofintegers]]
Out[12]= {{6, 8}, {9, 6}, {11, 11}, {12, 8}, {7, 13}, {1, 8}, {8, 8},
{10, 8}, {2, 7}, {5, 9}, {3, 4}, {0, 5}, {4, 5}}
Daniel Lichtblau
Wolfram Research
[toc] | [prev] | [next] | [standalone]
| From | Ray Koopman <koopman@sfu.ca> |
|---|---|
| Date | 2012-11-24 07:28 +0000 |
| Message-ID | <k8psuk$ird$1@smc.vnet.net> |
| In reply to | #12426 |
On Nov 23, 12:32 am, sylvieho...@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.
>
> I am trying to do more and more routine programming in Mathematica and after poking around in documentation for the past 4 hours have yet to find the parallel function in Mathematica for counting the integer frequency length in a big data set. My family wants me to drop everything and put the Turkey in the oven. My cat Sylvester even fell asleep on his back in front of the refrigerator with his little legs up in the air, so he want miss the transfer of the Turkey from the stove to the refrigerator. OH WELL -- IT'S SHOW TIME!
>
> Meanwhile, let me know any recommendations you have on a Mathematica function that parallels the SAS Function.
>
> Sylvia Hobbs
data = RandomInteger[9999, 100]
{6169, 9014, 239, 4874, 1339, 2885, 2828, 5885, 5372, 2491, 6211,
2833, 257, 5671, 3473, 5014, 2437, 1261, 9269, 9883, 587, 7745,
4909, 9986, 9510, 5161, 5278, 4182, 3251, 6873, 7248, 8240, 5027,
4364, 2660, 4769, 7637, 6913, 9587, 4991, 8116, 4252, 2981, 3840,
7352, 1616, 8446, 7901, 8812, 7688, 9850, 3611, 3359, 392, 8364,
180, 6287, 7749, 2951, 7420, 4604, 5137, 7893, 5008, 8839, 9027,
5122, 8253, 232, 6432, 2753, 4974, 9565, 4648, 1439, 9703, 1823,
2903, 8958, 5337, 5929, 9587, 4154, 4020, 1722, 377, 993, 1153,
3779, 3619, 2619, 1377, 2909, 8666, 4808, 2444, 125, 2867, 7919,
1029}
Sort @ Tally @ IntegerLength @ data
{{3, 9}, {4, 91}}
[toc] | [prev] | [next] | [standalone]
| From | Helen Read <readhpr@gmail.com> |
|---|---|
| Date | 2012-11-24 07:41 +0000 |
| Message-ID | <k8ptn9$j3c$1@smc.vnet.net> |
| In reply to | #12426 |
On 11/23/2012 3:30 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.
>
> I am trying to do more and more routine programming in Mathematica
> and after poking around in documentation for the past 4 hours have yet to
> find the parallel function in Mathematica for counting the integer
> frequency length in a big data set. My family wants me to drop
> everything and put the Turkey in the oven. My cat Sylvester even fell
> asleep on his back in front of the refrigerator with his little legs up
> in the air, so he want miss the transfer of the Turkey from the stove to
> the refrigerator. OH WELL -- IT'S SHOW TIME!
>
> Meanwhile, let me know any recommendations you have on a Mathematica
> function that parallels the SAS Function.
I'm not entirely certain what you are trying to do here (a small example
would help), but if I understand you correctly, have a look at
IntegerLength.
From the Documentation:
IntegerLength[n]
gives the number of digits in the base 10 representation of the integer n.
Under More Information, you will find that IntegerLength automatically
threads over lists. It ignores the sign of the integer.
IntegerLength[0], by the way, is 0.
Here's a small example, starting with a list of 25000 random integers in
the range from -10000 to 10000.
list = RandomInteger[{-10000, 10000}, 25000];
lengths = IntegerLength[list]; (* getting the lengths of all the
integers in the list *)
maxlength = Max[lengths]; (* find the maximum length if not already
known *)
Now use Count to find the frequency of each length up to the maxlength.
Count[lengths,0]
Count[lengths,1]
and so on.
To get them all at once, Map it across the range from 0 to maxlength.
Map[Count[lengths, #] &, Range[0, maxlength]]
Or better yet, generate a list of ordered pairs {n, frequency} like so.
Map[{#, Count[lengths, #]} &, Range[0, maxlength]]
--
Helen Read
University of Vermont
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web