Click or drag to resize

SampleStudentTTest Method (Double)

Tests whether the sample mean is compatible with the reference mean.

Namespace:  Meta.Numerics.Statistics
Assembly:  Meta.Numerics (in Meta.Numerics.dll) Version: 4.1.4
Syntax
public TestResult StudentTTest(
	double referenceMean
)

Parameters

referenceMean
Type: SystemDouble
The reference mean.

Return Value

Type: TestResult
The result of the test. The test statistic is a t-value. If t > 0, the one-sided likelyhood to obtain a greater value under the null hypothesis is the (right) propability of that value. If t < 0, the corresponding one-sided likelyhood is the (left) probability of that value. The two-sided likelyhood to obtain a t-value as far or farther from zero as the value obtained is just twice the one-sided likelyhood.
Exceptions
ExceptionCondition
InsufficientDataExceptionThere are fewer than two data points in the sample.
Remarks

The test statistic of Student's t-test is the difference between the sample mean and the reference mean, measured in units of the sample mean uncertainty. Under the null hypothesis that the sample was drawn from a normally distributed population with the given reference mean, this statistic can be shown to follow a Student distribution (StudentDistribution). If t is far from zero, with correspondingly small left or right tail probability, then the sample is unlikely to have been drawn from a population with the given reference mean.

Because the distribution of a t-statistic assumes a normally distributed population, this test should only be used only on sample data compatible with a normal distribution. The sign test (SignTest(Double)) is a non-parametric alternative that can be used to test the compatibility of the sample median with an assumed population median.

Examples

In some country, the legal limit blood alcohol limit for drivers is 80 on some scale. Because they have noticed that the results given by their measuring device fluctuate, the police perform three seperate measurements on a suspected drunk driver. They obtain the results 81, 84, and 93. They argue that, because all three results exceed the limit, the court should be very confident that the driver's blood alcohol level did, in fact, exceed the legal limit. You are the driver's lawyer. Can you make an argument to that the court shouldn't be so sure?

Here is some code that computes the probability of obtaining such high measured values, assuming that the true level is exactly 80.

C#
Sample values = new Sample();
values.Add(81, 84, 93);
TestResult result = values.StudentTTest(80);
return(result.RightProbability);

What level of statistical confidence do you think should a court require in order to pronounce a defendant guilty?

See Also