本文整理汇总了C#中Sample.SignTest方法的典型用法代码示例。如果您正苦于以下问题:C# Sample.SignTest方法的具体用法?C# Sample.SignTest怎么用?C# Sample.SignTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sample
的用法示例。
在下文中一共展示了Sample.SignTest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SignTestDistribution
public void SignTestDistribution()
{
// start with a non-normally distributed population
Distribution xDistribution = new ExponentialDistribution();
Random rng = new Random(1);
// draw 100 samples from it and compute the t statistic for each
Sample wSample = new Sample();
for (int i = 0; i < 100; i++) {
// each sample has 8 observations
Sample xSample = new Sample();
for (int j = 0; j < 8; j++) { xSample.Add(xDistribution.GetRandomValue(rng)); }
//Sample xSample = CreateSample(xDistribution, 8, i);
TestResult wResult = xSample.SignTest(xDistribution.Median);
double W = wResult.Statistic;
//Console.WriteLine("W = {0}", W);
wSample.Add(W);
}
// sanity check our sample of t's
Assert.IsTrue(wSample.Count == 100);
// check that the t statistics are distributed as expected
DiscreteDistribution wDistribution = new BinomialDistribution(0.5, 8);
// check on the mean
Console.WriteLine("m = {0} vs. {1}", wSample.PopulationMean, wDistribution.Mean);
Assert.IsTrue(wSample.PopulationMean.ConfidenceInterval(0.95).ClosedContains(wDistribution.Mean));
// check on the standard deviation
Console.WriteLine("s = {0} vs. {1}", wSample.PopulationStandardDeviation, wDistribution.StandardDeviation);
Assert.IsTrue(wSample.PopulationStandardDeviation.ConfidenceInterval(0.95).ClosedContains(wDistribution.StandardDeviation));
// check on the skew
Console.WriteLine("t = {0} vs. {1}", wSample.PopulationMomentAboutMean(3), wDistribution.MomentAboutMean(3));
Assert.IsTrue(wSample.PopulationMomentAboutMean(3).ConfidenceInterval(0.95).ClosedContains(wDistribution.MomentAboutMean(3)));
// check on the kuritosis
Console.WriteLine("u = {0} vs. {1}", wSample.PopulationMomentAboutMean(4), wDistribution.MomentAboutMean(4));
Assert.IsTrue(wSample.PopulationMomentAboutMean(4).ConfidenceInterval(0.95).ClosedContains(wDistribution.MomentAboutMean(4)));
// KS tests are only for continuous distributions
}