November 21, 2008

Henry Precheur

Einstein’s Intelligence Quiz: Bogus number and Phony statistic

Somebody posted this link on reddit. It’s a logical quiz called “Einstein’s Intelligence Quiz”, it’s challenging, I had fun solving it. Try it; it should keep you busy 20 minutes or more.

This test is also known as the Zebra Puzzle. And there is no prof that Einstein wrote it.

At the top of the page and you can read:

[Einstein] said that 98% of the people in the world cannot solve the quiz.

I guess this sentence was added to challenge the reader, being in the top 2% of the world population is something most would proud of. Oh … this is also a typical example of doubtful statistic.

Prefixing a statement with “Einstein said …” makes it true

Attributing this sentence to Einstein is a deceptive way of making it authoritative.

“Einstein was soooo smart, this is certainly true!”

Sorry but Einstein was a physicist; not a statistician or a psychologist. He was not qualified to give such number. One could argue that the statistical background to calculate reliably such a number is basic, and that Einstein could have mastered it very easily. That may be true, but to support this number, a representative sample of the world population is needed. And you can’t give such a precise number with only 10 or 20 people.

For example when giving the test to 10 people the maximum failure rate you can have is 90%. If all 10 fail, then the failure rate is 100%, which is too high. If only 9 fail it’s 90%.

The get a rate of 98% you need at least 50 participants: 1 who succeeds and 49 who fail. Einstein was a loner, it’s unlikely he would have carried such an experiment.

I don’t believe Einstein pulled this number out of his ass either. He was a scientist, he knew that such number would be bogus without a proper evaluation. He would probably have said “Most people” instead of “98% of the people”.

Phony statistic

“OK, maybe Einstein did not say such thing. That does not necessarily make this number bogus.”

The number is bogus no matter who is behind it. There is no context, which raises several objections about its validity:

  • There is no time limit to the test. I am not aware of any test measuring intelligence which does not have a time limit. This alone makes this number irrelevant.

  • The world population’s intelligence tends to raise. Access to a better education system makes a big difference. So when was this sentence supposed to be true? If this test was “validated” in the 50’s, it’s clear that this number does not hold anymore. IQ test are “normed” every 20 years or so. To be relevant today this quiz should certainly be changed to make sure 98% of today’s world population fails it; or the number itself should be changed.

  • The sample “98% of the people in the world” is dubious. Did the sampling really included a significant amount of people from poor regions of India, China, or Africa? Even now reaching these people is difficult. A sample composed mainly of Europeans and Americas is much more likely If anything was done to validate this “98%”.

  • Of course there is no statistical details about the number. What was the margin of error or the number of participants for example? Today’s world is very found of numbers without context, such details are usualy omitted. They are nonetheless important, each omission of those statistical details should raise suspicion.

My guess is: this number was invented to stimulate readers to do the quiz and was not supported by any actual data. I wonder how many people successfully completed the quiz are proudly claimed to be in the top 2% of the world population.

Statistics are more and more important in today’s world. Lots of decisions are based on them. It’s still difficult to make good decisions based on good statistics, let alone those based on bad ones…

I am not a statistician, and my knowledge is limited. But aberrant numbers like this one are easy to spot. I recommend you to read How to Lie with Statistics, an excellent introduction to statistics for the layman. If you are a programmer I also the recommend Zed Shaw’s article Programmers Need To Learn Statistics Or I Will Kill Them All.

by Henry Prêcheur (henry@precheur.org) at November 21, 2008 07:00 AM

November 04, 2008

Henry Precheur

ssh-copy-id

ssh-copy-id is a small script which copy your ssh public-key to a remote host; appending it to your remote authorized_keys.

$ ssh-copy-id root@192.168.1.1
root@192.168.1.1's password:
Now try logging into the machine, with "ssh 'root@192.168.1.1'", and check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

$ ssh root@192.168.1.1
Last login: Mon Nov  3 18:46:32 2008 from 192.168.1.32
OpenBSD 4.4 (GENERIC) #1021: Tue Aug 12 17:16:55 MDT 2008

Welcome to OpenBSD: The proactively secure Unix-like operating system.
# cat .ssh/authorized_keys
ssh-dss [removed] /home/henry/.ssh/id_dsa

This script is not shipped with OpenBSD. But it’s part of the Portable OpenSSH. It is self-contained, you just need to download and drop it in your ~/bin directory.

Download it from mindrot.org.

by Henry Prêcheur (henry@precheur.org) at November 04, 2008 05:02 AM

October 21, 2008

Henry Precheur

The Trek 7.3FX is awesome

After my bad experience with the Cannondale Quick 4, I exchanged it with a Trek 7.3FX.

Trek 7.3FX

It is light and fast. Overall it feels much better than the Cannondale. The only problem is the uncomfortable saddle, but I will change it.

by Henry Prêcheur (henry@precheur.org) at October 21, 2008 03:56 AM

October 17, 2008

Henry Precheur

The Cannondale Quick 4 is crap

My old bike, a Kuwahara Fastlane, was stolen 1 week ago. It was a cheap bike, but it served me well during 1 year.

Immediately after I started looking for a new one. I visited my local bike store the next day and the sale person suggested the Cannondale Quick 4. It looked more a less equivalent to the other bikes in this price range, but it had a carbon fork and supposedly better components. Far from being an expert, I was impressed by the carbon fork and bought the Quick 4.

The first few days were disappointing. The bike was not as light and fast as I hoped. The shape of the frame was not exactly good looking; the down tube was big, and made it look a bit goofy. The big down tube made it harder to lock the bike to something. And the gearing behaved weirdly a couple of time.

Last Tuesday, while I was riding home after work, a pedal suddenly broke while I was pedalling. I instantly lost my balance and fell heavily in the middle of the road. There was no car around and I did not fell too badly. I was lucky, it could have been worst. In the middle of the traffic I would have been hurt badly.

I got to the bike shop the day after to exchange it. This bike is clearly not worth its price. Some components are plain bad. This is not a $100 bike; for this range of price the components should be able to resist more than one week. A fancy carbon fork is not worth risking your life. The Cannondale Quick 4 is crap. Dont buy it.

by Henry Prêcheur (henry@precheur.org) at October 17, 2008 01:21 AM

September 23, 2008

Henry Precheur

Unicycle, a Vim plugin for typography junkies

I am not exactly a typography junky. But I read a fair number of books and I got used to good typography. But when it comes to good typographic practice, the web is quite poor. Even some well-known newspaper’s websites have a poor typography.

Here is what I mean by good and bad typography.

Bad:

"Hello -- my name is O'Brien ..."

Good:

“Hello – my name is O’Brien …”

Thanks to Unicycle –a Vim plugin– it is possible to get the right characters directly in Vim as long as your file is encoded in UTF-8.

A quick tour

The installation is quite simple. Download unicycle.vim, copy it to ~/.vim/plugin and restart Vim.

Open a file and type:

:UniCycleOn

Get into insertion mode and type ', instead of the classic straight quote (') You get an opening curly quote (‘). If you really want a straight quote ('), type ' again and you get it. To get a curly closing quote (’), type ' three times.

UniCycle has sensible defaults. If you type O'Brian, you won’t get O‘Brian, but O’Brian. And 'test' get turned automatically into ‘test’.

It also works for:

  • double quote: “Hello World”.
  • dashes: type hyphen 2 times to get a en-dash (–), 3 to get a em-dash (—) and 4 to a hyphen again.
  • ellipses: ‘...’ turns into ‘…’

Thanks to the author Jason Diamond for this plugin, which I will use and abuse.

by Henry Prêcheur (henry@precheur.org) at September 23, 2008 05:44 AM

September 13, 2008

Henry Precheur

Weblog 1.1

Weblog now supports Markdown's syntax and Atom feed generation. Many things had to be reworked internally in oder to support correctly Atom. This release is to be considered beta, some functionalities are not documented yet.

Jinja 1 is not supported anymore and I dropped RSS feed generation. Atom eats RSS for breakfast and maintaining 2 feed formats doesn't make sense, since both formats are widely supported.

The next release will focus on documentation and polishing. I want to make Weblog easy to use for newcomers, I will write a better tutorial and maybe add some more examples.

For now Weblog includes markdown2.py since markdown2 does not install correctly from pypi.python.org.

Download Weblog 1.1 or Weblog 1.1 + Jinja 2 (standalone version).

More informations and docs on Weblog's page. If you have any problems using it, don't hesitate to ask on weblog-users@googlegroups.com.

by Henry Prêcheur (henry@precheur.org) at September 13, 2008 08:42 PM

September 06, 2008

Henry Precheur

Weblog 1.0 released

Weblog 1.0 is out! After more than 1 year of development Weblog, a minimalist "blog publisher", is feature complete. All the stuffs I wanted to have are here.

Weblog is designed for people tired of all these crappy Database driven blogs (Wordpress and all his clones). It just reads a set of files and output static HTML files. Just upload these files on a server serving HTML files —pretty much everywhere— and you're done.

I used Weblog for 1 year, posted 32 articles with it. This project is used for real and has some documentation.

There are few changes in this version:

  • style.rst is now part of the distribution
  • The blog title now links to the base URL
  • Fixed a bug with renderstring when None or an empty string was passed
  • Use Jinja 2 instead of Jinja 1 if both versions are present

Download Weblog 1.0 or Weblog 1.0 + Jinja 2 (standalone version).

More informations and docs on Weblog's page. If you have any problems using it, don't hesitate to ask me: henry@precheur.

Even if Weblog has reached 1.0, the development is not over. Version 1.1 will include:

  • Markdown markup support, composing posts using raw HTML is not so fun in practice, and I really like Markdown's syntax.
  • Atom feed
  • Removal of the RSS feed. After a quick look at both standards, I think Atom is better than RSS. There is no need to have 2 different feeds format; 1 is enough.

by Henry Prêcheur (henry@precheur.org) at September 06, 2008 02:17 AM

September 04, 2008

Henry Precheur

RFC 3339 formatting in Python

Update This post is outdated now; I changed a few things in rfc3339.py since this post. I created a page for rfc3339. It contains an up-to-date version & documentation.


For those who don't know, RFC 3339 is a date format aiming to be simple and unambiguous:

1985-04-12T23:20:50.52Z

The date and hour use the ISO format and T is a marker to indicate where the time starts. The Z at the end indicates that the time is expressed in UTC

Non-UTC timezone are expressed like this:

1996-12-19T16:39:57-08:00

The RFC 3339 is used in Atom a feed format, I am planning to implement it for Weblog. I tried to find a function to convert date/time into RFC 3339 strings in Python, and what I found was disappointing:

  • PyFeed contains something to parse and generate RFC 3339 formatted dates. But it looks like it uses only timestamps and I want to use Python's datetime object. There was little documentation on the site and none in the package, just a few examples. What's the point of writing a library without proper documentation?
  • This little function is nice but too limited.
  • Formattime, a big project, again no documentation and depends on pytz and iso8601. Too big, 2 dependencies and not documented. You fail!

In the end I decided to write my own RFC 3339 conversion function. Simple, still powerful and documented! Dammit!

Here is a simple use case:

>>> import datetime
>>> import rfc3339
>>> rfc3339.rfc3339(datetime.datetime(2008, 9, 4, 12, 34))
'2008-09-04T12:34:00-07:00'

Download the file: rfc3339.py

Here is the documentation (yes, that's rough), generated via pydoc rfc3339.

Help on module rfc3339:

NAME
    rfc3339

FILE
    /home/henry/weblog/weblog/rfc3339.py

DESCRIPTION
    The function `rfc3339` formats dates according to the :RFC:`3339`. `rfc3339`
    tries to have as much as possible sensible defaults.

FUNCTIONS
    rfc3339(date, utc=False, use_system_timezone=True)
        Return a string formatted according to the :RFC:`3339`. If called with
        `utc=True`, it normalizes `date` to the UTC date. If `date` does not have
        any timezone information, uses the local timezone::
        
            >>> date = datetime.datetime(2008, 4, 2, 20)
            >>> rfc3339(date, utc=True, use_system_timezone=False)
            '2008-04-02T20:00:00Z'
            >>> rfc3339(date) # doctest: +ELLIPSIS
            '2008-04-02T20:00:00...'
        
        If called with `user_system_time=False` don't use the local timezone and
        consider the offset to UTC to be zero::
        
            >>> rfc3339(date, use_system_timezone=False)
            '2008-04-02T20:00:00+00:00'
        
        `date` must be a a `datetime.datetime` or a timestamp as returned by
        `time.time()`::
        
            >>> rfc3339(0, utc=True, use_system_timezone=False)
            '1970-01-01T00:00:00Z'
            >>> rfc3339(datetime.date.today())
            Traceback (most recent call last):
            ...
            TypeError: excepted datetime, got date instead
            >>> rfc3339('foo bar')
            Traceback (most recent call last):
            ...
            TypeError: excepted datetime, got str instead

DATA
    __all__ = ('rfc3339',)
    __author__ = 'Henry Precheur <henry@precheur.org>'
    __license__ = 'Public Domain'

AUTHOR
    Henry Precheur <henry@precheur.org>

The source code is in the Public domain

by Henry Prêcheur (henry@precheur.org) at September 04, 2008 04:55 AM

August 26, 2008

Henry Precheur

Switching to dwm

I just switched from wmii to dwm a light and hackable window manager.

dwm is really nice and simple, but I did not like that it reads its status bar text from stdin. Mainly because it took me a while to figure out how to make it work properly:

while true; do echo `date`; done | dwm

And displaying the date is simple enough to be done directly inside the dwm executable. I created a patch to make dwm displays the local date without reading the standard input.

It also saves a few lines of code ;)

Download the patch here.

by Henry Prêcheur (henry@precheur.org) at August 26, 2008 05:30 AM

Subscriptions