3

我们的代码库中有一个 PRNG,我们认为它在生成符合给定正态分布的数字的方法中存在错误。

是否有正常性测试的 C# 实现,我可以在我的单元测试套件中利用它来断言该模块的行为符合预期/预期?

我的偏好是具有以下签名的东西:

bool NormalityTest.IsNormal(IEnumerable<int> samples)
4

3 回答 3

1

Math.Net 具有分布函数和随机数采样。它可能是使用最广泛的数学库,非常扎实。

http://numerics.mathdotnet.com/

http://mathnetnumerics.codeplex.com/wikipage?title=Probability%20Distributions&referringTitle=Documentation

于 2013-09-25T17:12:51.040 回答
1

你可以试试这个:http ://accord-framework.net/docs/html/T_Accord_Statistics_Testing_ShapiroWilkTest.htm

向下滚动到示例:

// Let's say we would like to determine whether a set
// of observations come from a normal distribution:
double[] samples =
{
    0.11, 7.87, 4.61, 10.14, 7.95, 3.14, 0.46, 4.43,
    0.21, 4.75, 0.71, 1.52, 3.24, 0.93, 0.42, 4.97,
    9.53, 4.55, 0.47, 6.66
};

// For this, we can use the Shapiro-Wilk test. This test tests the null hypothesis 
// that samples come from a Normal distribution, vs. the alternative hypothesis that 
// the samples do not come from such distribution. In other words, should this test
// come out significant, it means our samples do not come from a Normal distribution.

// Create a new Shapiro-Wilk test:
var sw = new ShapiroWilkTest(samples);

double W = sw.Statistic; // should be 0.90050
double p = sw.PValue;    // should be 0.04209
bool significant = sw.Significant; // should be true

// The test is significant, therefore we should reject the null 
// hypothesis that the samples come from a Normal distribution.
于 2018-08-23T07:46:44.450 回答
0

我不知道任何用于正态性测试数据的c 实现。我遇到了同样的问题并建立了自己的例程。这个网页对我帮助很大。它是为在 Excel 中执行测试而编写的,但它为您提供了所有必要的系数 (Royston) 和逻辑。

于 2013-11-11T11:33:35.023 回答