28 Jun 2009
I finished “The Drunkard’s Walk – how randomness rules our lives”, by Leonard Mlodinow, a few days after Sway; I have postponed writing about it, because a minor storm of work has hit my parts – but I really loved this book, and thought I should say a few words about it.
The book’s point is that humans are very bad at drawing conclusions from observations of random phenomena. They routinely make gross mistakes when dealing with conditional probability (92% of Americans, some of them with pretty solid mathematical credentials, get the Monty Hall problem wrong), and fall prey to the Law of Small Numbers, seeing patterns where there is none, and refusing to admit the importance of randomness in shaping our fates. In the end, the message is pretty upbeat – I loved this quote from Thomas Watson:
If you want to succeed, double your failure rate.
I really enjoyed how the book builds up following the history of probability and statistics; some of the individuals who contributed to its development are truly remarkable (just lookup Cardano for instance), and the book contains a fair share of anecdotes about them. If anything, it gave me my first introduction to Benford’s law, which I am still digesting – and which has been weirdly prominent in the news, via the Iran election issue.
In short, I strongly recommend this book if you are interested in either history of sciences, probability, or decision making.
More...
24 Jun 2009
Since the longest time, I have been a member of Bay.Net, the San Francisco Bay Area .NET user group. It’s one of the largest user groups in the country (north of 4,000 members), very active, with four chapters in the Bay – and first and foremost, it’s a fantastic way to keep up with what is going on in the ever-changing .NET world, and meet fellow developers and fun people.
I initially came to attend the meetings, started to get more involved and volunteering in organizing events (if you are interested in volunteering, drop me a line!) – and I was very honored to be offered to co-chair the San Francisco chapter. The current chair, Kim Greenlee, has been doing an amazing job at lining up great speaker after another, and making the meetings fun to attend, but she wants to dedicate her energy to another Bay.Net related project, and can’t be full-time chair anymore, so… the pressure is on – I’ll do my best to keep it up!
More...
18 Jun 2009
Mark Twain famously said “There are three kinds of lies: lies, damned lies and statistics”; in that light, I found the following anecdote – from “The Drunkard’s Walk, a thoroughly enjoyable book so far - pretty funny.
Like most of his compatriots, Jules Henri Poincaré, the legendary French mathematician, took his bread seriously, and purchased a fresh loaf daily. Suspecting his baker was a cheat, he weights his loaves every day, and finds out the average weight is 950g instead of the 1000g advertised. He complains to the authorities – and his daily baguette suddenly becomes larger. But now, instead of enjoying his good life, Poincaré still suspects his baker is a cheat, and keeps on measuring his bread for an entire year, and finds out that he now got mostly larger than 1000g loaves, and too few light ones. For him it’s great; but from a statistics standpoint, this doesn’t sound right: he should have roughly as many small and large loaves. Poincaré concludes that the baker is still cheating, but gives him the biggest loaf of his inventory every day to pacify him. He calls the authorities in again, who confirm he is right, and slam the baker.
The moral of the story: don’t lie to statisticians!
More...
14 Jun 2009
While travelling to Seattle, I went shopping to the bookstore and purchased “Sway – the irresistible pull of irrational behavior”, by Ori and Rom Brafman. Each of the book’s chapter illustrates a specific bias which leads individuals to make poor decisions, through multiple experiments or real-life stories. If you are familiar with decision theory, and specifically with decision biases – the way our brain plays tricks with us and processes information poorly, misleading our judgment – you will probably not learn much from the book. Even then, it’s a pretty entertaining read; the style is light, and the anecdotes and cases funny and very clearly explained. If you are not familiar with the topic, I recommend the book: it is a good primer to recognize traps and make better decisions! The part which was new to me was the chapter “Compensation and Cocaine”. It seems that monetary decisions and altruism are processed in completely different parts of the brain (no surprise so far), but also that when one is active, it shuts down the other. Furthermore, the monetary decision brain is processed in the same place as the center of pleasure derived from sex, drugs or gambling (not sure what this says about the financial sector…), which has very practical implication in designing incentives. From what I gather, altruism provides a stronger motivation than money – but surprisingly, mixing both doesn’t add up: the pleasure center will completely override altruistic motivation, which is then ignored – and reduces overall motivation. Overall, fun read – recommended!
More...
08 Jun 2009
No matter how much you think you have your bases covered, users will do unexpected things with your application. Writing good unit tests: priceless. For everything else, there is logging. So I decided to add exception logging to Akin, and opted for NLog.
NLog rocks. It is very easy to configure: basically, add the NLog dll to your project, a configuration file defining what you want to log, and where it should go, and you are set. My configuration file looks something like that:
<?xml version="1.0" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="file" xsi:type="File"
layout="${longdate} ${stacktrace} ${message} ${exception:format=message,type,method,stacktrace}"
fileName="${basedir}/logs/${shortdate}.log"
concurrentWrites="true" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="file" />
</rules>
</nlog>
Which I use then to log exceptions this way:
try
{
// try to open a file
}
catch(Exception e)
{
logger.TraceException(string.Format("Failed to open {0}.", path), e);
}
The exception gets appended to a file like 2009-06-08.log, in the logs folder located in the application folder, in that case, C:\Program Files\Akin; if the file or folder do not exist, it gets automatically created. This worked like a charm, once I realized I also needed to add the config file to the installer.
And then I deployed on a Vista machine. Everything looked fine (I checked that logging to a message box worked), except that… there was no log file to be found. Damn.
After much anxiety and help of StackOverflow, I found my logs. Turns out, there was a log file, but not where I expected it to be. Vista uses File System Virtualization, and writes the log to another location – in my case,
C:/Users/JohnDoe/AppData/Local/VirtualStore/Program Files (x86)/Akin/Logs/
So if you can’t find your log files, no worries. It’s just Vista playing hide-and-seek with you…
More...