On 07/14/2013 05:01 PM, Toki Kantoor wrote:
On 07/13/2013 11:01 PM, Brian Barker wrote:
Unless I misunderstand,the formula =10^RAND() should create random variates in
the range (1,10) following the law.
10^RAND generates a set of random numbers that does _not_ adhere to
Benford's Law. I need a random number generator whose output does
adhere to Benford's Law.
jonathon
Hey Jonathon,
This is the distribution I got after 100 million cycles:
10^RAND
9 - 0.045
8 - 0.051
7 - 0.057
6 - 0.066
5 - 0.079
4 - 0.096
3 - 0.124
2 - 0.176
1 - 0.300
I don't think you are going to get any closer to Benford's law
distribution than that.
Here is the code I used:
use strict;
use warnings;
my $num;
my $lpcnt;
my @Distribution;
$Distribution[0]=0;
srand;
$lpcnt = 100000000;
while ($lpcnt) {
$num=substr(10**rand(),0,1);
++$Distribution[$num];
--$lpcnt;
}
$lpcnt = 9;
while ($lpcnt) {
print "$lpcnt - ".substr($Distribution[$lpcnt]/100000000,0,5)."\n";
--$lpcnt;
}
--
_
°v°
/(_)\
^ ^ Mark LaPierre
Registered Linux user No #267004
https://linuxcounter.net/
****
--
To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted