Saturday January 28, 2006Checking out Benford's Law...I spend far too much time following links on Boing Boing, Digg, and Slashdot, but they're really rather addictive (and make a nice break from my other activities :-). Anyway, after reading a fascinating article on Benford's Law (courtesy of Digg), I decided to check its assertions for myself...Benford's Law asserts that the distribution of the first digits in many sets of numbers will follow the function "log10(1 + 1/d)", where 'd' is the value of the digit. So, for example, '1' will the leading digit about 30% of the time. Although the article gives a plausible explanation, the assertion sounds so odd that I wanted to check it out for myself. As it happens, I have a plausible data set very close at hand: the byte counts of the files on my Mac OS X system. So, I hacked up a bit of Perl code to walk the file tree, tallying the file sizes. Here's the code:
There's no real magic in the code above.
It just does a depth-first traversal of the file tree,
calling the "
Although there is certainly some variation from the pred(icted) values,
the file system data follows the expected curve about as well as some
of the data shown in the article.
I also suspect that the file size distribution may be skewed
by certain "systematic" effects
(e.g., integral numbers of blocks in some types of binary files).
In any case, it's enough to convince me...
Technorati Tags: Benford's Law, mathematics, Perl
Checking out Benford's Law...
in
Computers
,
Science
,
Technology
- posted at Sat, 28 Jan, 22:19 Pacific
| «e»
| TrackBack
|