本文整理汇总了C#中Sample.StudentTTest方法的典型用法代码示例。如果您正苦于以下问题:C# Sample.StudentTTest方法的具体用法?C# Sample.StudentTTest怎么用?C# Sample.StudentTTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sample
的用法示例。
在下文中一共展示了Sample.StudentTTest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TTestDistribution
public void TTestDistribution()
{
// start with a normally distributed population
Distribution xDistribution = new NormalDistribution(2.0, 3.0);
Random rng = new Random(1);
// draw 100 samples from it and compute the t statistic for each
Sample tSample = new Sample();
for (int i = 0; i < 100; i++) {
// each sample has 9 values
Sample xSample = new Sample();
for (int j = 0; j < 9; j++) {
xSample.Add(xDistribution.GetRandomValue(rng));
}
//Sample xSample = CreateSample(xDistribution, 10, i);
TestResult tResult = xSample.StudentTTest(2.0);
double t = tResult.Statistic;
Console.WriteLine("t = {0}", t);
tSample.Add(t);
}
// sanity check our sample of t's
Assert.IsTrue(tSample.Count == 100);
// check that the t statistics are distributed as expected
Distribution tDistribution = new StudentDistribution(9);
// check on the mean
Console.WriteLine("m = {0} vs. {1}", tSample.PopulationMean, tDistribution.Mean);
Assert.IsTrue(tSample.PopulationMean.ConfidenceInterval(0.95).ClosedContains(tDistribution.Mean), String.Format("{0} vs. {1}", tSample.PopulationMean, tDistribution.Mean));
// check on the standard deviation
Console.WriteLine("s = {0} vs. {1}", tSample.PopulationStandardDeviation, tDistribution.StandardDeviation);
Assert.IsTrue(tSample.PopulationStandardDeviation.ConfidenceInterval(0.95).ClosedContains(tDistribution.StandardDeviation));
// do a KS test
TestResult ksResult = tSample.KolmogorovSmirnovTest(tDistribution);
Assert.IsTrue(ksResult.LeftProbability < 0.95);
Console.WriteLine("D = {0}", ksResult.Statistic);
// check that we can distinguish the t distribution from a normal distribution?
}