我使用高斯过程进行预测。现在让我们假设我预测了大小为 1900 X 1 的x
值存储。现在我想检查它的分布是否遵循高斯分布。我需要这个来比较其他方法预测值(如 NN、KNN(的分布函数,以判断哪个方法遵循平滑高斯或正态分布函数
我怎么能做到这一点? 如果我能以数值数据的形式得到一些结果,那就更好了。代码编写如下,
m = mean(ypred); % mean of r
s = std(ypred); % stdev of r
pd = makedist('Normal','mu',m,'sigma',s); % make probability distribution with mu = m and sigma = s
[h,p] = kstest(ypred,'CDF',pd); % calculate probability that it is a normal distribution
ypred
值是从 matlab fitrgp
获得的输出。此处附ypred
值示例
[图]2 是测量值和预测值的残差qq_plot
。
您可以进行单样本柯尔莫哥罗夫-斯米尔诺夫测试:
x = 1 + 2.*randn(1000,1); % just some random normal distributed data, replace it with your actual 1900x1 vector.
m = mean(x); % mean of r
s = std(x); % stdev of r
pd = makedist('Normal','mu',m,'sigma',s); % make probability distribution with mu = m and sigma = s
[h,p] = kstest(x,'CDF',pd); % calculate probability that it is a normal distribution
其中p
是它服从正态分布的概率,如果原假设被否定且显著性为 0.05,则h = 1
。由于原假设是"它服从正态分布",h = 0
意味着它是正态分布的。
由于x
在这个例子中是从正态分布中采样的,很可能是h = 0
和p > 0.05
。如果您运行上面的代码
x = 1 + 2.*rand(1000,1); % sampled from uniform distribution
h
很可能是 1 和 p<0.05
.当然,您可以将整个内容写成一行,以避免创建m
,s
和pd
。