[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The Prize #3



When grilled further on (Tue, 21 Sep 2004 02:27:40 +0930),
Fraser Farrell <fraser@trilobytes.com.au> confessed:

> 
> But I would expect the magnitude's second and subsequent digits to follow 
> Benford's Law. Easy enough to check of course, using a trivial change to your 
> SQL.
> 

The results below make some sense to me.  The first will be biased since the
majority of magnitudes are in the 11, 12 and 13 range, while the second is a
'normal' distribution I would expect, not following Benford's Law.  At the
least, I'm having SQL fun ;-)

tassiv=# select count(*), mag_v::int as mag_bin from catalog where mag_v != 99
group by mag_bin order by mag_bin;
 count  | mag_bin 
--------+---------
      4 |       3
     15 |       4
     71 |       5
    437 |       6
   2139 |       7
   8098 |       8
  24978 |       9
  62763 |      10
 118746 |      11
 203595 |      12
 253230 |      13
  78344 |      14
    223 |      15
      7 |      16


If I constructed this correctly...  From inside to outside, the replace removes
the '.' in the magnitude, the "substring ... from 2" takes the string from the
second digit on, and the "substring ... from '[1-9]'" selects the first non-zero
digit of the remainder.  So, the second non zero digit:

tassiv=# select count(*), substring( substring( replace( mag_v::text, '.', '')
from 2) from '[1-9]') as fd fr om catalog where mag_v != 99 group by fd order by
fd;
 count  | fd 
--------+----
 166715 | 1
 261089 | 2
 200934 | 3
  27788 | 4
  16498 | 5
  17865 | 6
  19127 | 7
  20412 | 8
  22220 | 9

And the third non zero digit:

tassiv=# select count(*), substring( substring( replace( mag_v::text, '.', '')
from 3) from '[1-9]') as fd fr om catalog where mag_v != 99 group by fd order by
fd;
 count | fd 
-------+----
 84965 | 1
 84651 | 2
 84817 | 3
 83971 | 4
 84166 | 5
 84333 | 6
 82530 | 7
 81858 | 8
 81282 | 9

Cheers,
Rob

-- 
 21:27:17 up 15 days,  9:31,  4 users,  load average: 2.44, 2.24, 2.20
Linux 2.6.5-02 #8 SMP Mon Jul 12 21:34:44 MDT 2004

PGP signature