The Sign Test using C#

I wrote an article titled “The Sign Test using C#” in the February 2017 issue of Microsoft’s MSDN Magazine. See


The Sign Test is a statistical test designed to infer if there was some sort of an effect based on before-and-after data. The classic example is a weight loss drug. Suppose you weigh 8 people, and their weights (in kg) are:

70, 80, 75, 85, 70, 75, 50, 60

Then you give the 8 people some sort of weight loss drug and weigh them again a few weeks later and the new weights are:

65, 78, 72, 87, 68, 74, 48, 63

Of the 8 people, 6 lost weight but 2 people gained weight. The idea of the Sign Test is to assume there’s no effect, then you calculate how likely the observed data is. For this example, if there was truly no effect, then the probability of seeing 6 (or more) weight losses is only 0.1445 therefore you can conclude there appears to be an effect of some sort.


My article shows how to do all these calculations in a C# program. Of course there are tools, such as R, that can perform a Sign Test, but such tools can be difficult or impossible to integrate into a system written using a different language. And such tools are a black box so you wouldn’t understand what’s going on.

The Sign Test is designed for simple problems, but the test is surprisingly subtle and somewhat difficult to understand.

This entry was posted in Machine Learning. Bookmark the permalink.