在 MATLAB 中测试数据分布是否服从高斯分布

发布于 2024-08-14 11:12:10 字数 154 浏览 5 评论 0原文

我有一些数据点及其平均值。我需要找出这些数据点(具有该平均值)是否遵循高斯分布。 MATLAB 中有可以进行此类测试的函数吗?或者我需要自己编写测试吗?

我尝试查看 MATLAB 提供的不同统计函数。我对 MATLAB 很陌生,所以我可能忽略了正确的函数。

干杯

I have some data points and their mean point. I need to find whether those data points (with that mean) follows a Gaussian distribution. Is there a function in MATLAB which can do that kind of a test? Or do I need to write a test of my own?

I tried looking at different statistical functions provided by MATLAB. I am very new to MATLAB so I might have overlooked the right function.

cheers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

忱杏 2024-08-21 11:12:10

检查所有 可用的假设检验

根据您的目的,您可以使用:

... 其中其他

您还可以使用一些视觉测试,例如:

Check this documentation page on all available hypothesis tests.

From those, for your purpose you can use:

... among others

You can also use some visual tests like:

双马尾 2024-08-21 11:12:10

我喜欢 Spiegelhalter 的测试(DJ Spiegelhalter,“分布形状的诊断测试”,Biometrika,1983):

function pval = spiegel_test(x)
% compute pvalue under null of x normally distributed;
% x should be a vector;
xm = mean(x);
xs = std(x);
xz = (x - xm) ./ xs;
xz2 = xz.^2;
N = sum(xz2 .* log(xz2));
n = numel(x);
ts = (N - 0.73 * n) / (0.8969 * sqrt(n)); %under the null, ts ~ N(0,1)
pval = 1 - abs(erf(ts / sqrt(2)));    %2-sided test.

每当进行统计测试时,总是在零下测试它们!这是一个简单的例子:

pvals = nan(10000,1);
for j=1:numel(pvals);
pvals(j) = spiegel_test(randn(300,1));
end
nnz(pvals < 0.05) ./ numel(pvals)

我得到结果:

ans =    
   0.0505

同样

nnz(pvals > 0.95) ./ numel(pvals)

我得到

ans = 
   0.0475

I like Spiegelhalter's test (D. J. Spiegelhalter, 'Diagnostic tests of distributional shape,' Biometrika, 1983):

function pval = spiegel_test(x)
% compute pvalue under null of x normally distributed;
% x should be a vector;
xm = mean(x);
xs = std(x);
xz = (x - xm) ./ xs;
xz2 = xz.^2;
N = sum(xz2 .* log(xz2));
n = numel(x);
ts = (N - 0.73 * n) / (0.8969 * sqrt(n)); %under the null, ts ~ N(0,1)
pval = 1 - abs(erf(ts / sqrt(2)));    %2-sided test.

whenever hacking statistical tests, alway test them under the null! here's a simple example:

pvals = nan(10000,1);
for j=1:numel(pvals);
pvals(j) = spiegel_test(randn(300,1));
end
nnz(pvals < 0.05) ./ numel(pvals)

I get the results:

ans =    
   0.0505

Similarly

nnz(pvals > 0.95) ./ numel(pvals)

I get

ans = 
   0.0475
深爱不及久伴 2024-08-21 11:12:10

对于一般测试,请在统计工具箱中查找 Kolmogorov-Smirnov 测试,如 kstest 和两个示例版本:

For testing in general, look up the Kolmogorov-Smirnov Test, also in the Stats Toolbox, as kstest and the two-sample version: kstest2 . You feed it your empirical data, (and the data from a possible function, like the gaussian, etc...) then it tests the likelihood that your sample was pulled from the normal distribution (or the one you supplied for the two-sample version)... The nicety is that it'll work for any possible distributions...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文