Test Run. The T-Test Using C#

James McCaffrey. 2015-11-01.
The t-test is one of the most fundamental forms of statistical analysis. Its goal is to determine whether the means (averages) of two sets of numbers are equal when you only have samples of the two sets. The idea is best explained by example. Suppose you’re investigating the mathematical ability of high school males and females in a large school district. The ability test is expensive and time-consuming so you can’t give the test to all the students. Instead, you randomly select a sample of 10 males and 10 females and give them the math test. From the sample results you can perform a t-test to infer whether the true average score of all the males is equal to the true average score of all the females.
There are many standalone tools, including Excel, which can perform a t-test. But if you want to integrate t-test functionality directly into a software system, using standalone tools can be awkward or impossible, and may involve copyright or other legal issues. This article explains how to perform a t-test using raw (no external libraries) C# code.