public void StatisticToPValueTest()
{
double df = 2.2;
double t = 1.96;
{
TTest target = new TTest(t, df, OneSampleHypothesis.ValueIsDifferentFromHypothesis);
Assert.AreEqual(DistributionTail.TwoTail, target.Tail);
double actual = target.StatisticToPValue(t);
double expected = 0.1773;
Assert.AreEqual(expected, actual, 1e-4);
}
{
TTest target = new TTest(t, df, OneSampleHypothesis.ValueIsSmallerThanHypothesis);
Assert.AreEqual(DistributionTail.OneLower, target.Tail);
double actual = target.StatisticToPValue(t);
double expected = 0.9113;
Assert.AreEqual(expected, actual, 1e-4);
}
{
TTest target = new TTest(t, df, OneSampleHypothesis.ValueIsGreaterThanHypothesis);
Assert.AreEqual(DistributionTail.OneUpper, target.Tail);
double actual = target.StatisticToPValue(t);
double expected = 0.0887;
Assert.AreEqual(expected, actual, 1e-4);
}
t = -1.96;
{
TTest target = new TTest(t, df, OneSampleHypothesis.ValueIsDifferentFromHypothesis);
Assert.AreEqual(DistributionTail.TwoTail, target.Tail);
double actual = target.StatisticToPValue(t);
double expected = 0.1773;
Assert.AreEqual(expected, actual, 1e-4);
}
{
TTest target = new TTest(t, df, OneSampleHypothesis.ValueIsSmallerThanHypothesis);
Assert.AreEqual(DistributionTail.OneLower, target.Tail);
double actual = target.StatisticToPValue(t);
double expected = 0.0887;
Assert.AreEqual(expected, actual, 1e-4);
}
{
TTest target = new TTest(t, df, OneSampleHypothesis.ValueIsGreaterThanHypothesis);
Assert.AreEqual(DistributionTail.OneUpper, target.Tail);
double actual = target.StatisticToPValue(t);
double expected = 0.9113;
Assert.AreEqual(expected, actual, 1e-4);
}
}