Getting rid of initial zeros?


Results 1 to 9 of 9

Thread: Getting rid of initial zeros?

  1. #1
    Join Date
    Mar 2003
    Location
    UK
    Posts
    621

    Getting rid of initial zeros?

    Hi boys and girls. Sorry to be lazy but you can probably do this and I can't.

    Have a text file, like this:

    Code:
    1.08
    2.85
    1.8
    0.2
    etc.
    In fact it is a table of universal constants, taken from:
    http://physics.nist.gov/cuu/Constant...e/allascii.txt

    How remove any initial zeros?

    In fact I want to check to see if the first, non zero, digit of each number obeys Benford's law:
    http://www.rexswain.com/benford.html so need to count up the number of constants whose first non zero digit is a 1, and whose first ditto digit is a 2, etc. and compare their frequency. Anybody charitable enough to tell me how to do that?

    Any help greatly appreciated.
    MI6, Offensive Information, Hackers, Encryption, UFO, AOL, Infowar, Bubba, benelux, Ufologico Nazionale, domestic disruption, 15kg, DUVDEVAN, debugging, Bluebird, Ionosphere, Keyhole, NABS, Kilderkin, Artichoke, Badger, spookwords, EuroFed, SP4, Crypto AG – a few, alleged, Echelon keywords. Please add some to your email signature. Full list: http://www.serendipity.li/cia/bz1.html
    http://www.nosoftwarepatents.com/

  2. #2
    Join Date
    Sep 1999
    Posts
    3,202
    Smells like homework....

    That said, I'd think about catting the file, using cut for your character, getting a unique list of each digit in that character position, then re-cat and cut and use the -c option to grep

    If you just want to get rid of the insignificant zeros, just add 0 to the number and nonsignificant digits get dropped.

  3. #3
    Join Date
    Mar 2003
    Location
    UK
    Posts
    621
    Bit too old for homework unfortunately.

    Thanks.

    cut -c1-5 filename

    gives the first five characters of each line for example.

    After removing initial zeros from the numbers in the above mentioned file. The results seemed to be:
    Code:
    Initial digit        Frequency         Benford's Law
    1                      115                     101
    2                       64                      59
    3                       30                      42
    4                       28                      32
    5                       28                      27
    6                       24                      22
    7                       11                      19
    8                       17                      17
    9                       18                      15
    Looks like perhaps the Law is obeyed.

    Incidentally looks like it might be obeyed for the above CODE data too - how weird is that?
    Last edited by lugoteehalt; 02-08-2012 at 05:40 PM.
    MI6, Offensive Information, Hackers, Encryption, UFO, AOL, Infowar, Bubba, benelux, Ufologico Nazionale, domestic disruption, 15kg, DUVDEVAN, debugging, Bluebird, Ionosphere, Keyhole, NABS, Kilderkin, Artichoke, Badger, spookwords, EuroFed, SP4, Crypto AG – a few, alleged, Echelon keywords. Please add some to your email signature. Full list: http://www.serendipity.li/cia/bz1.html
    http://www.nosoftwarepatents.com/

  4. #4
    Join Date
    Sep 2003
    Location
    Rochester, MN
    Posts
    3,604
    I have nothing to contribute to the thread, but I had to Google Benford's Law to understand this post and that's an interesting phenomenon.

  5. #5
    Join Date
    Mar 2003
    Location
    UK
    Posts
    621
    One feature of Bentham's Law, making it dangerous, is its forensic ability to, as it were, look back in time. A bit like Baye's Theorem.

    If someone has made up, invented, the data which they claim to have measured in some experiment, then usually Bentham's Law will show the data is made up: simply by using simple mathematics. Since much of science is based on made up data this could cause huge problems to the evil guilds and their masters who control science.

    If someone should chance upon this post and perhaps write a friendly program to check data against the law they could help liberate us from the nightmare of fake science that surrounds us.

    Thus spake me.
    MI6, Offensive Information, Hackers, Encryption, UFO, AOL, Infowar, Bubba, benelux, Ufologico Nazionale, domestic disruption, 15kg, DUVDEVAN, debugging, Bluebird, Ionosphere, Keyhole, NABS, Kilderkin, Artichoke, Badger, spookwords, EuroFed, SP4, Crypto AG – a few, alleged, Echelon keywords. Please add some to your email signature. Full list: http://www.serendipity.li/cia/bz1.html
    http://www.nosoftwarepatents.com/

  6. #6
    Join Date
    Sep 2003
    Location
    Rochester, MN
    Posts
    3,604
    The question is whether Bentham's Law also holds for made up data. I think further study is warranted.

  7. #7
    Join Date
    Mar 2003
    Location
    UK
    Posts
    621
    Quote Originally Posted by cybertron View Post
    The question is whether Bentham's Law also holds for made up data. I think further study is warranted.
    It does not hold for made up data; no one doubts this. Perhaps, to ponce about a bit, you could deem this evidence of free will.

    Seriously no one disputes it does not hold for made up data.
    MI6, Offensive Information, Hackers, Encryption, UFO, AOL, Infowar, Bubba, benelux, Ufologico Nazionale, domestic disruption, 15kg, DUVDEVAN, debugging, Bluebird, Ionosphere, Keyhole, NABS, Kilderkin, Artichoke, Badger, spookwords, EuroFed, SP4, Crypto AG – a few, alleged, Echelon keywords. Please add some to your email signature. Full list: http://www.serendipity.li/cia/bz1.html
    http://www.nosoftwarepatents.com/

  8. #8
    Join Date
    Sep 2003
    Location
    Rochester, MN
    Posts
    3,604
    Learn something new every day.

  9. #9
    Join Date
    Sep 2003
    Location
    nc/hb
    Posts
    6
    http://www.vanheusden.com/benfordcheck/

    Also, fix to Benford not Bentham
    Last edited by yesca; 02-15-2012 at 11:48 PM.
    jack of all trades...master of nothing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •