<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
    <title>Lawrence Kesteloot's writings</title> 
    <link>http://www.teamten.com/lawrence/writings/</link> 
    <description>Lawrence Kesteloot's writings</description> 
    <language>en-us</language> 
    <copyright>Copyright 1993-2009 Lawrence Kesteloot.</copyright> 
    <managingEditor>Lawrence Kesteloot</managingEditor> 

    <item>
        <title><![CDATA[In Defense of Design Patterns]]></title>
        <link>http://www.teamten.com/lawrence/writings/in_defense_of_design_patterns.html</link>
        <author>Lawrence Kesteloot</author>
        <guid isPermaLink="true">http://www.teamten.com/lawrence/writings/in_defense_of_design_patterns.html</guid>
        <pubDate>06 Oct 2009</pubDate>
        <description><![CDATA[

            <p class="very-first">It&rsquo;s fashionable to bash software design patterns.
                &ldquo;The Singleton Pattern? You mean, <em>a global variable?</em>
                Hahaha!&rdquo; It&rsquo;s hilarious. But I&rsquo;ve noticed that those who
                mock are also, curiously, those who&rsquo;ve not learned about them.
                I think they (the patterns) serve a useful purpose.</p>

            <p>My analogy is to data structures. Imagine that we didn&rsquo;t have
                names for data structures, and you had to repeatedly say,
                &ldquo;Let&rsquo;s put data in objects where each object has a reference
                to the next object, and the last reference is null, and we keep
                track of only the first one.&rdquo; It&rsquo;d be hard to communicate. There&rsquo;s
                a bunch of information in your head associated with the name
                <em>linked list</em> and without the term you wouldn&rsquo;t be
                able to organize it or communicate effectively about it.</p>

            <p>Design patterns are just that: names for common ways of organizing
                code, so instead of saying, &ldquo;Let&rsquo;s make a class that you can
                configure and then ask it to atomically make another object so
                that the other object doesn&rsquo;t need a long constructor or ever
                be in a half-constructed state,&rdquo; you can just say, &ldquo;Let&rsquo;s use
                the Builder Pattern.&rdquo; Along with the name comes a shared understanding
                of how and when to implement it, advantages and drawbacks, and
                what to call the class.</p>

            <div style="float:right"><a href="http://www.amazon.com/gp/product/0201633612?ie=UTF8&tag=lkesteloot&linkCode=as2&camp=1789&creative=390957&creativeASIN=0201633612"><img border="0" src="51Rs5KgdLTL._SL160_.jpg"></a><img src="http://www.assoc-amazon.com/e/ir?t=lkesteloot&l=as2&o=1&a=0201633612" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></div>

            <p>People often crack open a pattern book and say, &ldquo;There&rsquo;s nothing
                new here!&rdquo; That&rsquo;s the <em>point</em>. It&rsquo;s for code structures that
                we&rsquo;ve been using for a long time but never had a name for.
                In fact, seen that way, it&rsquo;s a bit ridiculous
                to bash design patterns. Why <em>wouldn&rsquo;t</em> you want to
                name to a commonly-used thing?</p>

        ]]></description>
    </item>

    <item>
        <title><![CDATA[Asking &ldquo;Why&rdquo; in Interviews]]></title>
        <link>http://www.teamten.com/lawrence/writings/asking_why_in_interviews.html</link>
        <author>Lawrence Kesteloot</author>
        <guid isPermaLink="true">http://www.teamten.com/lawrence/writings/asking_why_in_interviews.html</guid>
        <pubDate>01 Oct 2009</pubDate>
        <description><![CDATA[

            <p class="very-first">The question &ldquo;Why?&rdquo; can be interpreted
                to mean &ldquo;What&rsquo;s the cause?&rdquo; or &ldquo;What&rsquo;s the purpose?&rdquo;
                Why do you go to work every day? The cause is the employment
                agreement, the purpose is to make money. Some questions have
                only a cause (&ldquo;Why do you like spinach?&rdquo; &ldquo;Why did the sun
                rise this morning?&rdquo;).</p>

            <p>In everyday conversations I try to ask the unambiguous form
                of the question, but when interviewing job candidates I&rsquo;ve
                found it useful to keep it ambiguous to see which one they&rsquo;ll
                pick. It reflects something about the way they think.</p>

            <p>For example, I&rsquo;ll ask a senior database administrator (DBA)
                candidate what
                style he uses to name tables (capitalization, prefixes,
                underscores, pluralization). I have a preferred answer
                to this, but whatever answer they give
                I&rsquo;ll ask, &ldquo;Why?&rdquo; Most candidates will interpret this to
                mean, &ldquo;What&rsquo;s the cause?&rdquo; and will answer &ldquo;Because that&rsquo;s
                what the style guidelines say at my company.&rdquo;</p>

            <p>At this point the interview is pretty much over, but I&rsquo;ll usually
                ask something like, &ldquo;Well what if you worked here?&rdquo; The
                answer is usually, &ldquo;I&rsquo;d follow your guidelines.&rdquo;</p>

            <p>&ldquo;What if you had to write the guidelines?&rdquo;</p>
            <p>&ldquo;I&rsquo;d use the same ones.&rdquo;</p>
            <p>&ldquo;Why?&rdquo; (again)</p>
            <p>&ldquo;Cause that&rsquo;s what&rsquo;s in the guidelines of the company I work for now.&rdquo;</p>

            <p>At no point is the candidate considering the &ldquo;purpose&rdquo; interpretation,
                which is the interpretation I&rsquo;d expect from a senior candidate.
                He should be thinking about the benefits of the style he&rsquo;s using
                over the alternatives. Not doing so shows a lack of introspection,
                and someone who doesn&rsquo;t introspect won&rsquo;t improve and isn&rsquo;t senior.</p>

            <p>My ideal conversation would go something like this:</p>
            <p>&ldquo;What style do you use for table names?&rdquo;</p>
            <p>&ldquo;All lower case, with underscores between words, singular.&rdquo;</p>
            <p>&ldquo;Why?&rdquo;</p>
            <p>&ldquo;Uppercase can cause problems in some dialects because of the
                case-insensitive nature of the parsers, and you&rsquo;ll get different
                results on Windows and Unix with MySQL because they use the table name
                for filenames. Underscores make it more readable, and singular reads
                better in most places (though not in the actual join clause).&rdquo;</p>
            <p>At that point the interview is also over, but in a good way.</p>

        ]]></description>
    </item>

    <item>
        <title><![CDATA[Every Line Is a Potential Bug]]></title>
        <link>http://www.teamten.com/lawrence/writings/every_line_is_a_potential_bug.html</link>
        <author>Lawrence Kesteloot</author>
        <guid isPermaLink="true">http://www.teamten.com/lawrence/writings/every_line_is_a_potential_bug.html</guid>
        <pubDate>19 Sep 2009</pubDate>
        <description><![CDATA[

            <p class="very-first">Last summer I wrote some code to get
                a message out of a hash table. The message was going to be put
                there by another thread. There was a small chance of a race
                where it wouldn&rsquo;t be there yet when I initially looked for it.
                The code looked something like this:</p>

            <pre>
    while ((message = map.get(key)) == null
        && System.currentTimeMillis() &lt; timeoutTime) {

        wait(1000);
    }</pre>

            <p class="first">The <tt>wait()</tt> call blocks the thread,
                waiting for the <tt>notifyAll()</tt> from the thread that puts
                the message into the map.  The 1000 means one second. The
                timeout was going to be on the order of five seconds.</p>

            <p>The above code is simple and correct. It&rsquo;ll just keep looping until
                the value comes in or until it has timed out. The timeout may go
                over by up to one second, but that&rsquo;s not a problem in this case.
                (Or rather, by the time that happens, you&rsquo;ve got more serious problems.)</p>

            <p>The code was reviewed by two other people. Both complained that the
                <tt>wait()</tt> should wait for the time between now and the timeout,
                not just one second. They argued that my code wakes up the thread
                five times unnecessarily. I replied that the key was very
                likely to be there within the first second, and that waking up
                a thread is not very expensive. I argued that their proposed code
                was more complex, and therefore more likely to have bugs.</p>

            <p>They both said, <em>&ldquo;One subtraction is not complex!&rdquo;</em>, went
                back to their desks, and emailed me their modified versions, just
                to prove how simple it could be. Both had introduced a bug.
                One person&rsquo;s bug was straightforward: he used the wrong
                constant for the calculation.  But the second person&rsquo;s bug was
                subtle:</p>

            <pre>
    while ((message = map.get(key)) == null
        && System.currentTimeMillis() &lt; timeoutTime) {

        wait(<span class="code_highlight">timeoutTime - System.currentTimeMillis()</span>);
    }</pre>

            <p class="first">There&rsquo;s a small chance that the current time will
                have advanced by the time the subtraction is done, resulting in
                a negative value passed to <tt>wait()</tt> and an
                <tt>IllegalArgumentException</tt> getting thrown. In order to
                save the computer one rare thread switch, he introduced a bug
                that would have occasionally and mysteriously caused operations
                to fail.</p>

            <p>Every line of code you write is a potential bug. Do not write any
                line of code unless you absolutely need it <em>right now</em> and
                your program will suffer for the lack of it. Do not write routines
                speculatively. Do not write abstraction layers you don&rsquo;t need right
                now. If an optimization will add any complexity whatsoever, even
                a subtraction, resist it. You will be sorry in five years when
                your code is riddled with potentially-buggy code that you never
                really needed to write.</p>

        ]]></description>
    </item>

    <item>
        <title><![CDATA[Hiring in a Recession]]></title>
        <link>http://www.teamten.com/lawrence/writings/hiring_in_a_recession.html</link>
        <author>Lawrence Kesteloot</author>
        <guid isPermaLink="true">http://www.teamten.com/lawrence/writings/hiring_in_a_recession.html</guid>
        <pubDate>15 Sep 2009</pubDate>
        <description><![CDATA[

            <p class="very-first">You&rsquo;d think that in a recession
                companies would have an easier time hiring. They should
                be flooded by resumes because of the high unemployment
                rate. But I think that recruiting actually gets harder,
                for two reasons.</p>

            <p>The first is that many lay-offs are
                actually firings. Companies don&rsquo;t dare fire too many
                people when times are good because the public may
                perceive the company as having problems. But in a
                recession the company can get rid of its 10% lowest-performing
                employees and blame it on the economy. Some companies
                do get rid of entire projects, where both good and
                poor employees are lost, but hiring is so difficult
                that a company will typically try to keep the best
                employees before flushing the rest.</p>

            <p>The second reason is that good employees, those not
                getting laid off, hold on more tightly to their jobs.
                An employee might normally be thinking, &ldquo;This job
                isn&rsquo;t so great, I bet I could do better.&rdquo; In a recession,
                though, he&rsquo;ll be thankful just to be employed.
                His current situation is likely to seem more stable
                and safe than a position in another company.</p>

            <p>During a recession, then, companies with good hiring
                standards must find it harder to hire, because although
                they are flooded with resumes, those resumes are of lower
                average quality.</p>
        ]]></description>
    </item>

    <item>
        <title><![CDATA[Paid Vacation]]></title>
        <link>http://www.teamten.com/lawrence/writings/paid_vacation.html</link>
        <author>Lawrence Kesteloot</author>
        <guid isPermaLink="true">http://www.teamten.com/lawrence/writings/paid_vacation.html</guid>
        <pubDate>10 Sep 2009</pubDate>
        <description><![CDATA[

            <p class="very-first">When you quit a salaried job, you get a check
                for the vacation days you have left. They calculate the daily
                rate using your pro-rated salary. Every vacation day you take
                now is one less day&rsquo;s worth of pay that you&rsquo;ll get when
                you quit. So there&rsquo;s no such thing as &ldquo;paid vacation&rdquo;. It&rsquo;s all
                unpaid: &ldquo;unpaid&rdquo; vacation is unpaid today, whereas &ldquo;paid&rdquo;
                vacation is unpaid later.</p>

            <p>One exception is when you max out your vacation days. Then
                you may as well take them or they&rsquo;re lost anyway.</p>

            <p>I unfortunately discovered this ten years ago, and ever since
                then my vacations have cost a lot more because I count
                the reduced check that I&rsquo;ll get when I eventually quit.</p>
        ]]></description>
    </item>

    <item>
        <title><![CDATA[OurGroceries]]></title>
        <link>http://www.teamten.com/lawrence/writings/ourgroceries.html</link>
        <author>Lawrence Kesteloot</author>
        <guid isPermaLink="true">http://www.teamten.com/lawrence/writings/ourgroceries.html</guid>
        <pubDate>14 Aug 2009</pubDate>
        <description><![CDATA[

            <p class="very-first">My friend Dan Collens and I have written (and
                today published) an iPhone app called <a
                    href="http://www.headcode.com/ourgroceries/"
                    class="external">OurGroceries</a>. It keeps track of your
                grocery list and shares it with other members of your
                household. It&rsquo;s free, supported by ads. I&rsquo;m curious to see how
                well it will do. There are many grocery list apps for the iPhone,
                but we couldn&rsquo;t find any that lets you sync up the list with other
                people. Also it&rsquo;s one of the few free ones.</p>

            <div class="image">
                <center>
                    <img src="ourgroceries.png" width="199" height="417">
                </center>
            </div>

        ]]></description>
    </item>

    <item>
        <title><![CDATA[Depth-First Programming]]></title>
        <link>http://www.teamten.com/lawrence/writings/depth_first_programming.html</link>
        <author>Lawrence Kesteloot</author>
        <guid isPermaLink="true">http://www.teamten.com/lawrence/writings/depth_first_programming.html</guid>
        <pubDate>24 Jul 2009</pubDate>
        <description><![CDATA[

            <p class="very-first">Writing a computer program is like
                traversing a tree. Going deeper into the tree means filling
                in methods with more detail. The breadth of
                the tree is all the work that needs to be done.</p>

            <p>My impatience leads me to a <em>breadth-first programming</em> style.
                I quickly write a minimal program that accomplishes the task (a quick pass
                of the breadth at a high level), then fill out more and
                more detail (descend into the depth of the tree), adding minor
                functionality, error checking, edge case handling, comments,
                documentation, refactoring, etc.</p>

            <p>Another approach is <em>depth-first programming</em>, where
                you write your first method perfectly,
                handling every error condition and special case, writing copious
                comments, and so on. Then
                you move on to the second method. It&rsquo;s exhausting to work this
                way. There&rsquo;s no feedback to keep you motivated. You can&rsquo;t run
                the program at all until you&rsquo;ve written every line.</p>

            <p>In theory both methods lead to the same program, just in a
                different order. In practice, though, they each have different
                problems. The major problem with the breadth-first approach is
                that, at some point, the program will be &ldquo;good enough&rdquo;
                and you&rsquo;ll move on to another program. From your boss&rsquo;s point
                of view this makes sense: there&rsquo;s more value in your starting
                something new than polishing your current program. Programs
                written this way don&rsquo;t bottom out the tree.</p>

            <p>There are two problems with the depth-first approach. The first is
                that if you run out of time, you have nothing. This happened
                to a co-worker who worked for three months on a program
                and when the deadline came he hadn&rsquo;t yet implemented the
                &ldquo;save&rdquo; feature. The rest of the program was
                gorgeous, but the client couldn&rsquo;t use it for his project and
                another program was used instead. During the same three
                months I wrote a program breadth-first; it was used immediately
                and is still being used 14 years later.</p>

            <p>The second problem is that if you realize part-way through that
                you designed your program poorly, or to changing requirements,
                then you&rsquo;ve wasted a lot of time polishing routines that
                get thrown out altogether.</p>

            <p>So what&rsquo;s the best way to write a program? I&rsquo;ve spent the last
                15 years trying to move from breadth-first to depth-first,
                despite its two drawbacks. I find it easier to bottom-out
                each routine one at a time, rather than later finding the
                permission or self-motivation to go back and do a polish pass.
                The quality of the resulting program is therefore higher. The
                code looks better. There are fewer bugs, less unfinished business.</p>

            <p>What about the two drawbacks? It&rsquo;s true that you might run out of
                time, but I&rsquo;ve only seen that once and presumably it&rsquo;s manageable
                with either a flexible deadline or a conservative schedule. The
                second problem is wasted effort, but that&rsquo;s acceptable to me
                if the result is of higher quality.</p>

            <p>Avoiding &ldquo;unfinished business&rdquo; is important, at least in a work
                environment. After you&rsquo;ve been at a place for a few years you
                are haunted by every little missing comment, missing error
                check, missing little feature, unpolished routine, every
                unhandled edge case, sloppy parsing, outdated documentation,
                unreproducible crash. You do nothing but apologize for
                and fix your old code. It&rsquo;s dreadful. You leave the company in frustration
                and your successor convinces your manager to rewrite everything
                you&rsquo;ve done, because &ldquo;it would be easier than fixing it.&rdquo;</p>

            <p>My co-worker had the last laugh, because four years later he was
                writing new code while I was cursing that original program
                I&rsquo;d written sloppily in a breadth-first way.</p>

        ]]></description>
    </item>

    <item>
        <title><![CDATA[Are Stocks a Random Walk?]]></title>
        <link>http://www.teamten.com/lawrence/writings/are_stocks_a_random_walk.html</link>
        <author>Lawrence Kesteloot</author>
        <guid isPermaLink="true">http://www.teamten.com/lawrence/writings/are_stocks_a_random_walk.html</guid>
        <pubDate>19 Jul 2009</pubDate>
        <description><![CDATA[

            <p class="very-first">A co-worker has been day-trading for the
                last few months, and I&rsquo;ve been teasing him about the negative
                average returns of day traders. (Day traders always think that
                they have a deterministic way to end up on the winning side
                of average.) Last week he gave some explanation for recent
                stock behavior, and I reminded him that stocks just follow
                a random walk and that he wouldn&rsquo;t be able to tell a stock
                graph from a random walk. He told me that he absolutely would,
                and the challenge was on.</p>
            
            <p>(I learned later that he thought I meant
                a truly random graph, where each day is a random number. I don&rsquo;t
                know whether he would have taken the challenge had he known
                that I was referring to a random walk, which is a value that
                goes up or down by some random amount each day.)</p>

            <p>He said that a six-month interval would be easiest to distinguish,
                so I went for 130 days, which is the number of weekdays in six months.
                I generated six graphs of random walks with 130 samples. I also chose
                six stocks off the top of my head, downloaded their history
                from Yahoo Finance, and for each one picked a random six-month
                interval. I then normalized all twelve graphs vertically.</p>

            <p>The next day I gave him the twelve printouts and asked him to separate
                them into two piles: stocks and random. Other people got interested
                and gave it a shot. One person deliberately separated them
                randomly, without looking at the charts.</p>

            <p>If done randomly, I would expect six of the twelve charts to be in
                the correct pile.
                In fact there&rsquo;s a 43% chance of getting six right, out of twelve.
                There&rsquo;s a 24% chance of getting four or eight right, 4% chance of
                getting two or ten, and a 0.1% chance of getting none or all
                twelve correct. (You&rsquo;re always getting an even number right
                because every stock you think is random results in a random you
                think is a stock.)</p>

            <table cellpadding="0" cellspacing="0" id="stock-probabilities">
                <tr>
                    <th>Number right:</th>
                    <td>0</td>
                    <td>2</td>
                    <td>4</td>
                    <td>6</td>
                    <td>8</td>
                    <td>10</td>
                    <td>12</td>
                </tr>
                <tr>
                    <th>% probability:</th>
                    <td>0.1</td>
                    <td>3.9</td>
                    <td>24.3</td>
                    <td>43.3</td>
                    <td>24.3</td>
                    <td>3.9</td>
                    <td>0.1</td>
                </tr>
            </table>

            <p class="first">We decided ahead of time that if he got ten or twelve right, he
                would be able to claim that stocks look different than a random
                walk. If he got four, six, or eight right, then either they
                look the same or he can&rsquo;t tell the difference. If he got none
                or two, then they&rsquo;re different but he&rsquo;s got it backwards.</p>

            <p>Here are the results. The day-trader is person V, who spent about
                ten minutes sorting the twelve charts. Persons W, X,
                and Y looked briefly at the charts. Person Z picked randomly
                without looking at the charts. The green and red colors represent
                correct and incorrect guesses, respectively.</p>

            <table cellpadding="0" cellspacing="0" id="stock-results">
                <tr>
                    <th>Chart</th>
                    <th>Symbol</th>
                    <th>Person V</th>
                    <th>Person W</th>
                    <th>Person X</th>
                    <th>Person Y</th>
                    <th>Person Z</th>
                    <th>Score</th>
                </tr>
                <tr>
                    <td>A</td>
                    <td>Random</td>
                    <td class="correct">Random</td>
                    <td class="wrong">Stock</td>
                    <td class="wrong">Stock</td>
                    <td class="correct">Random</td>
                    <td class="wrong">Stock</td>
                    <td>2 of 5</td>
                </tr>
                <tr>
                    <td>B</td>
                    <td>SWY</td>
                    <td class="wrong">Random</td>
                    <td class="wrong">Random</td>
                    <td class="wrong">Random</td>
                    <td class="correct">Stock</td>
                    <td class="wrong">Random</td>
                    <td>1 of 5</td>
                </tr>
                <tr>
                    <td>C</td>
                    <td>YHOO</td>
                    <td class="correct">Stock</td>
                    <td class="wrong">Random</td>
                    <td class="wrong">Random</td>
                    <td class="correct">Stock</td>
                    <td class="wrong">Random</td>
                    <td>2 of 5</td>
                </tr>
                <tr>
                    <td>D</td>
                    <td>IBM</td>
                    <td class="correct">Stock</td>
                    <td class="wrong">Random</td>
                    <td class="wrong">Random</td>
                    <td class="wrong">Random</td>
                    <td class="correct">Stock</td>
                    <td>2 of 5</td>
                </tr>
                <tr>
                    <td>E</td>
                    <td>Random</td>
                    <td class="wrong">Stock</td>
                    <td class="wrong">Stock</td>
                    <td class="wrong">Stock</td>
                    <td class="wrong">Stock</td>
                    <td class="wrong">Stock</td>
                    <td>0 of 5</td>
                </tr>
                <tr>
                    <td>F</td>
                    <td>AIG</td>
                    <td class="wrong">Random</td>
                    <td class="correct">Stock</td>
                    <td class="correct">Stock</td>
                    <td class="wrong">Random</td>
                    <td class="correct">Stock</td>
                    <td>3 of 5</td>
                </tr>
                <tr>
                    <td>G</td>
                    <td>Random</td>
                    <td class="wrong">Stock</td>
                    <td class="wrong">Stock</td>
                    <td class="wrong">Stock</td>
                    <td class="correct">Random</td>
                    <td class="correct">Random</td>
                    <td>2 of 5</td>
                </tr>
                <tr>
                    <td>H</td>
                    <td>CIT</td>
                    <td class="wrong">Random</td>
                    <td class="wrong">Random</td>
                    <td class="wrong">Random</td>
                    <td class="correct">Stock</td>
                    <td class="wrong">Random</td>
                    <td>1 of 5</td>
                </tr>
                <tr>
                    <td>I</td>
                    <td>Random</td>
                    <td class="correct">Random</td>
                    <td class="correct">Random</td>
                    <td class="wrong">Stock</td>
                    <td class="correct">Random</td>
                    <td class="wrong">Stock</td>
                    <td>3 of 5</td>
                </tr>
                <tr>
                    <td>J</td>
                    <td>Random</td>
                    <td class="wrong">Stock</td>
                    <td class="wrong">Stock</td>
                    <td class="correct">Random</td>
                    <td class="wrong">Stock</td>
                    <td class="correct">Random</td>
                    <td>2 of 5</td>
                </tr>
                <tr>
                    <td>K</td>
                    <td>Random</td>
                    <td class="wrong">Stock</td>
                    <td class="wrong">Stock</td>
                    <td class="wrong">Stock</td>
                    <td class="wrong">Stock</td>
                    <td class="correct">Random</td>
                    <td>1 of 5</td>
                </tr>
                <tr>
                    <td>L</td>
                    <td>MMM</td>
                    <td class="wrong">Random</td>
                    <td class="wrong">Random</td>
                    <td class="wrong">Random</td>
                    <td class="wrong">Random</td>
                    <td class="correct">Stock</td>
                    <td>1 of 5</td>
                </tr>
                <tr class="score">
                    <td colspan="2">Score</td>
                    <td>4 of 12</td>
                    <td>2 of 12</td>
                    <td>2 of 12</td>
                    <td>6 of 12</td>
                    <td>6 of 12</td>
                    <td>&nbsp;</td>
                </tr>
            </table>

            <p class="first">The person who picked randomly got half of them
                right, unsurprisingly. So did another person who looked at
                the charts briefly. The day-trader did slightly worse
                than average, but still within the reasonable bounds of
                randomness. Surprisingly, though, two people did so badly that
                they imply that there is indeed a difference between stocks
                and a random walk. There was only a 4% chance of them getting
                so few right.</p>

            <p>The right-most column shows the number of correct guesses for
                a given graph. Graphs E, K, and L managed to fool all four people
                who looked at them. (Person Z wasn&rsquo;t looking.) The graphs are
                shown at the bottom of this page.</p>

            <p>So what did we learn? I&rsquo;m not sure we learned much. One could
                argue that I removed too much information from the stock data.
                (I graphed only opening prices, not close, low, or high.) I
                didn&rsquo;t include any information about events, such as quarterly
                reports.</p>

            <p>What I was really trying to show was that it&rsquo;s not possible
                to reliably make money from day trading because it&rsquo;s akin to
                trying to predict a random walk. I&rsquo;m not sure that I&rsquo;ve proven
                that. Just because it&rsquo;s indistinguishable from a random walk
                after the fact doesn&rsquo;t mean that the path of the walk couldn&rsquo;t
                have been predicted.</p>

            <p>I could repeat the experiment with two changes: adding
                candlestick marks for low, high, open, and close; and not 
                normalizing vertically. That&rsquo;s more like what a day trader would
                see.</p>

            <p>But perhaps comparing to randomness is irrelevant. Maybe I should
                pick a real stock&rsquo;s historical period, hide the last 10%, and ask
                people to predict the last 10% based on the first 90%. I may have
                to add various information about price/equity ratio and whatnot.
                It&rsquo;s getting complicated. Or maybe I just should read
                <a href="http://www.amazon.com/gp/product/0812975219?ie=UTF8&tag=lkesteloot&linkCode=as2&camp=1789&creative=390957&creativeASIN=0812975219" class="external">Fooled by Randomness</a>,
                which will just point me
                to the studies that have done all this already.</p>

            <div class="update">
                <p>Update 9/10/2009: I&rsquo;ve now read the book and he doesn&rsquo;t
                    cover this specifically. I highly recommend the book,
                    though.</p>
            </div>

            <p class="new-section">Below are the graphs along with some information
                about them.  You can also download the Python script and stock
                data that were used to make the graphs:
                <a href="are_stocks_a_random_walk/make_graphs.py">make_graphs.py</a>,
                <a href="are_stocks_a_random_walk/AIG.csv">AIG.csv</a>,
                <a href="are_stocks_a_random_walk/CIT.csv">CIT.csv</a>,
                <a href="are_stocks_a_random_walk/IBM.csv">IBM.csv</a>,
                <a href="are_stocks_a_random_walk/MMM.csv">MMM.csv</a>,
                <a href="are_stocks_a_random_walk/SWY.csv">SWY.csv</a>, and
                <a href="are_stocks_a_random_walk/YHOO.csv">YHOO.csv</a>.</p>

            <img src="are_stocks_a_random_walk/A.png" class="stock-random-graph"/>
            <p class="first">A: 130-point random walk. Two out of four people
            thought this was a stock.</p>

            <img src="are_stocks_a_random_walk/B.png" class="stock-random-graph"/>
            <p class="first">B: 130 days of SWY starting May 22, 1991. Three out
            of four people thought this was a random walk.</p>

            <img src="are_stocks_a_random_walk/C.png" class="stock-random-graph"/>
            <p class="first">C: 130 days of YHOO starting September 7, 2005. Two out
            of four people thought this was a random walk.</p>

            <img src="are_stocks_a_random_walk/D.png" class="stock-random-graph"/>
            <p class="first">D: 130 days of IBM starting September 10, 1980. Three out
            of four people thought this was a random walk.</p>

            <img src="are_stocks_a_random_walk/E.png" class="stock-random-graph"/>
            <p class="first">E: 130-point random walk. All four people
            thought this was a stock.</p>

            <img src="are_stocks_a_random_walk/F.png" class="stock-random-graph"/>
            <p class="first">F: 130 days of AIG starting October 18, 2002. Two out
            of four people thought this was a random walk.</p>

            <img src="are_stocks_a_random_walk/G.png" class="stock-random-graph"/>
            <p class="first">G: 130-point random walk. Three out of four people
            thought this was a stock.</p>

            <img src="are_stocks_a_random_walk/H.png" class="stock-random-graph"/>
            <p class="first">H: 130 days of CIT starting June 19, 2008. Three out
            of four people thought this was a random walk.</p>

            <img src="are_stocks_a_random_walk/I.png" class="stock-random-graph"/>
            <p class="first">I: 130-point random walk. One out of four people
            thought this was a stock.</p>

            <img src="are_stocks_a_random_walk/J.png" class="stock-random-graph"/>
            <p class="first">J: 130-point random walk. Three out of four people
            thought this was a stock.</p>

            <img src="are_stocks_a_random_walk/K.png" class="stock-random-graph"/>
            <p class="first">K: 130-point random walk. All four people
            thought this was a stock.</p>

            <img src="are_stocks_a_random_walk/L.png" class="stock-random-graph"/>
            <p class="first">L: 130 days of MMM starting December 13, 2002.
            All four people thought this was a random walk.</p>

        ]]></description>
    </item>

    <item>
        <title><![CDATA[Vowels in English]]></title>
        <link>http://www.teamten.com/lawrence/writings/vowels_in_english.html</link>
        <author>Lawrence Kesteloot</author>
        <guid isPermaLink="true">http://www.teamten.com/lawrence/writings/vowels_in_english.html</guid>
        <pubDate>07 Mar 2009</pubDate>
        <description><![CDATA[

            <p class="very-first">Years ago I worked on speech software and learned
                that speech recognition is hard because all the energy is in the
                vowels but all the intelligence is in the consonants. That&rsquo;s why
                whispering works. Extracting voice out of noise is difficult
                because the sounds that matter, the consonants, sound a lot like
                the noise. You get all the vowels, but they don&rsquo;t help much.</p>
            
            <p>Our son Milo is starting to write, and I&rsquo;m learning that lesson again.
                When I ask him to spell a word, such as &ldquo;hat&rdquo;, he&rsquo;ll just come up
                with &ldquo;H&rdquo; and &ldquo;T&rdquo;, as if he&rsquo;s spelling the whispered version of it.
                He&rsquo;s focusing on the parts that matter.</p>

            <p>Making this harder is that, in English, every vowel can sound like just
                about any other vowel. For example, the bold vowels here all sound
                the same: t<b>e</b>rse, f<b>i</b>rst, w<b>o</b>rse, and p<b>u</b>rse.
                For A and O you&rsquo;ve got b<b>a</b>ll and <b>o</b>strich as well
                as p<b>a</b>l and v<b>o</b>wels. When Milo chooses the wrong
                vowel (which is about half the time), the vowel he guesses does
                make that sound in another word.</p>

            <p>It won&rsquo;t be long before we switch to memorization (sometimes called
                &ldquo;sight words&rdquo;). Logic can&rsquo;t take you far with English.</p>

        ]]></description>
    </item>

    <item>
        <title><![CDATA[Personal Motivation]]></title>
        <link>http://www.teamten.com/lawrence/writings/personal_motivation.html</link>
        <author>Lawrence Kesteloot</author>
        <guid isPermaLink="true">http://www.teamten.com/lawrence/writings/personal_motivation.html</guid>
        <pubDate>02 Mar 2009</pubDate>
        <description><![CDATA[

            <p class="very-first">The first project I took on after college was
                a 3D painting program. I predicted that it would take me three
                months to write it, and it did. Later
                my manager told me that I was good at making such estimates.
                I tried <em>really</em> hard after that to get my estimates
                right and to hit them.</p>

            <p>Common sense tells us that criticizing someone will motivate
                them to try harder, and praising them will let them slack off.
                Here the praise motivated me. Why? I felt that I had built a
                good reputation, and keeping a good reputation is easier than
                building it. I was therefore motivated to never
                disappoint my manager. I knew that a single missed estimate would
                require many more good ones to regain his trust.</p>

            <p>I use this technique on my son all the time. I&rsquo;ll say things like,
                &ldquo;You&rsquo;re really good at sharing, Milo,&rdquo; after he shared a toy.
                Even if he&rsquo;s not all that good at sharing, this will (I hope)
                motivate him to maintain that good reputation.</p>

            <p>I hate to floss. I suppose we all do, but I have found it particularly
                hard to be motivated. This is because, without exception, at every
                cleaning the dental hygienist tells me that I should floss
                more. There&rsquo;s never any praise. This is even after the periods when
                I did a pretty good job flossing. I think if she said, &ldquo;You&rsquo;re good
                at flossing, I can see that,&rdquo; I would floss a lot more. It wouldn&rsquo;t
                even need to be true, though it shouldn&rsquo;t be completely false or
                I&rsquo;ll see through it.</p>

            <p>Twice at dental cleanings she told me that I&rsquo;m good at keeping the
                far ends of my teeth clean (the sides of the very back teeth). Guess
                which part I&rsquo;m most excited about brushing?</p>

            <p>It&rsquo;s counter-intuitive, but someone who&rsquo;s doing a 75%
                job at something can probably be motivated to improve by
                pretending that you think he&rsquo;s doing even better than that. It&rsquo;s
                difficult, as a manager, to do this. You feel like a 75% achiever doesn&rsquo;t
                <em>deserve</em> the praise, and they don&rsquo;t. But it may be the
                best way to get the results you want.</p>

        ]]></description>
    </item>

</channel>
</rss>
