如何定量检验正态分布的有效性?
How do I test the validity of my normal distribution quantitatively?
我试图确定通过以下方式获得的正态分布的有效性:
xfit<-seq(min(x),max(x),length=1000)
yfit<-dnorm(xfit,mean=mean(x),sd=sd(x))
在我的这段代码摘录中,x 是一个数组,其中约 300 个值介于 -15 和 -5 之间。
我通过以下方式将其与直方图和 Q-Q 图进行比较来评估分布:
#Fitting in histogram with normal curve
x <- dataM31
h<-hist(x, breaks=10, col="red", xlab="Absolute Magnitude", prob = TRUE)
xfit<-seq(min(x),max(x),length=1000)
yfit<-dnorm(xfit,mean=mean(x),sd=sd(x))
lines(xfit, yfit, col="blue", lwd=2)
#Create a normality test plot (qq-plot)
x_norm <- (x - mean(x))/sd(x)
qqnorm(x_norm); abline(0,1)
我已经尝试对这种正态分布的有效性进行任何类型的定量测试,但我找不到一个函数来对一维数据数组和二维正态分布进行这种测试。是否有任何功能可以相对轻松地为我完成此操作,或者我是否应该完全重写我的代码才能使其正常工作?
这些函数提供了正态性检验和密度估计的解决方案,运行在控制台中查看示例:
?shapiro.test()
?ks.test()
?density()
我试图确定通过以下方式获得的正态分布的有效性:
xfit<-seq(min(x),max(x),length=1000)
yfit<-dnorm(xfit,mean=mean(x),sd=sd(x))
在我的这段代码摘录中,x 是一个数组,其中约 300 个值介于 -15 和 -5 之间。
我通过以下方式将其与直方图和 Q-Q 图进行比较来评估分布:
#Fitting in histogram with normal curve
x <- dataM31
h<-hist(x, breaks=10, col="red", xlab="Absolute Magnitude", prob = TRUE)
xfit<-seq(min(x),max(x),length=1000)
yfit<-dnorm(xfit,mean=mean(x),sd=sd(x))
lines(xfit, yfit, col="blue", lwd=2)
#Create a normality test plot (qq-plot)
x_norm <- (x - mean(x))/sd(x)
qqnorm(x_norm); abline(0,1)
我已经尝试对这种正态分布的有效性进行任何类型的定量测试,但我找不到一个函数来对一维数据数组和二维正态分布进行这种测试。是否有任何功能可以相对轻松地为我完成此操作,或者我是否应该完全重写我的代码才能使其正常工作?
这些函数提供了正态性检验和密度估计的解决方案,运行在控制台中查看示例:
?shapiro.test()
?ks.test()
?density()