【问题标题】:How do I test the validity of my normal distribution quantitatively?如何定量测试我的正态分布的有效性?
【发布时间】:2017-08-04 10:48:17
【问题描述】:

我试图确定我通过以下方式获得的正态分布的有效性:

xfit<-seq(min(x),max(x),length=1000)
yfit<-dnorm(xfit,mean=mean(x),sd=sd(x))

在我的代码的这段摘录中,x 是一个数组,其中有大约 300 个值在 -15 和 -5 之间。

我通过以下方式将分布与直方图和 QQ 图进行比较来评估分布:

#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)

我已尝试对此正态分布的有效性进行任何类型的定量测试,但我找不到针对 1D 数据数组与 2D 正态分布执行此操作的函数。是否有任何功能可以相对轻松地为我做到这一点,或者我应该完全重写我的代码以使其工作?

【问题讨论】:

    标签: r histogram normal-distribution


    【解决方案1】:

    这些函数提供了正态性检验和密度估计的解决方案,在控制台中运行并查看示例:

    ?shapiro.test()
    ?ks.test()
    ?density()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-17
      • 2013-07-17
      • 2015-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多