Mathias Brandewinder on .NET, F#, VSTO and Excel development, and quantitative analysis / machine learning.
8. July 2010 11:03

A new method of forecasting has been brought to my attention: Paul. Paul is an English-born octopus, currently living in Germany, and has been predicting with high accuracy the results of the German soccer team, by picking between two boxes marked with the flag of the two competing teams:

How unlikely is it that Paul would have such a string of correct forecasts? Pretty unlikely. If you assume that Paul’s picks were completely random, with a 50% chance of correctly calling the winner, the probability of making 11 good calls out of 12 comes down to 0.29%. Does this mean Paul is the next big thing in forecasting? It’s possible, but I don’t think so (this said with all due respect to Paul and his skills). Leonard Mlodinow, in his excellent book, The Drunkard's Walk, makes the following comment:

This example illustrates an important point: even with data significant at, say, the 3 percent level, if you test 100 nonpsychic people for psychic abilities […], you ought to expect a few people to show up as psychic.

In other words, if a phenomenon is random, you should typically see the “average” case regularly, but you should also see highly unlikely cases happen from time to time – observing such a rare occurrence doesn’t contradict the randomness of the phenomenon. Or, in the words of the French poet Mallarmé, Un Coup de Dés Jamais N'Abolira Le Hasard (A throw of the Dice will Never Abolish Chance).

15. March 2009 09:46

I was writing some code yesterday, and need to generate different "names" for objects. Rather than using Guid.NewGuid(), I decided (for no clear reason) to append a random int generated by System.Random, with code looking something like that:

public string CreateRandomName()
{
Random randomizer = new Random();
return randomizer.Next().ToString();
}

All looked great, until I wrote code like this:

[Test]
public void CreateInstancesWithDifferentNames()
{
var firstInstance = new MyClass();
firstInstance.Name = CreateRandomName();
var secondInstance = new MyClass();
secondInstance.Name = CreateRandomName();
Assert.AreNotEqual(firstInstance.Name, secondInstance.Name);
}


I expected each instance to have a different name, but the test fails miserably. Both instances get a random number, but... they get the same random number.

More...

#### Need help with F#?

The premier team for
F# training & consulting.