【问题标题】:Central limit theorem in [R][R] 中的中心极限定理
【发布时间】:2012-02-21 22:37:29
【问题描述】:

我正在使用语言 [R] 生成一个样本,其中包含 M = 32000 个平均值,每个平均值是通过对随机变量连续均匀分布 (0, 1) 的 36 个独立值进行平均计算得出的,生成如下:

sampleA<-1:32000

for ( i in 1:32000){
    MuestraAUnif<- runif(36)
    sampleA[i]<-mean(MuestraAUnif)
}

对于生成的样本,请我计算大于 L = 0.32 +4 * 1 / 100 的观察平均值的相对频率,并将其与平均 N 值大于的概率(近似为“Central limit theorem”)进行比较L.如下:

    L<- 0.32+4*1/100
    sigma<- sqrt(1/12) #(b-a)/12 
    miu = 0.5 #(a+b)/2
    greaterA <-sum(sampleA > L) #values of the sample greater than L are 23693
    xBar<- greaterA/length(sampleA) 
    X <- sum(sampleA) 
    n<-32000
    Zn<- (X - n*miu)/(sigma*sqrt(n))

    cat("P(xBar >",L,") = P(Z>", Zn, ")=","1 - P (Z < ", Zn,") =",1-pnorm(Zn),"\n") #print the theoretical prob Xbar greater than L
    cat("sum (sampleA >",L,")/","M=", n," para N =", 36,":",xBar, "\n") #print the sampling probability print when is greater than L

输出是:

P(xBar > 0.36 ) = P(Z> -3.961838 )= 1 - P (Z <  -3.961838 ) = 0.9999628 
sum (sampleA > 0.36 )/ M= 32000  para N = 36 : 0.7377187 

我的问题是:为什么这么远的值​​​?,大概它们应该更接近(0.9999628与0.7377187相差甚远)。我的实施有问题吗?请原谅我的英语。

【问题讨论】:

    标签: r statistics probability normal-distribution probability-theory


    【解决方案1】:

    Melkhiah66。你做的一切都是对的,只会改变 MuestraAUnif&lt;- runif(2)MuestraAUnif&lt;- runif(32) 它应该可以工作

    【讨论】:

    • 我已经做了,是我复制的错误,但仍然无法正常工作或没有告诉我想要的结果
    • 我正在使用SEET.SEED(129)和获取:总和(SAMPLEA> 0.359999999999999866773)/ M = 32000.0000000000000000000000000000000000000000/099812500000000/099812500000000/099812500000000/099812500000000/099812500000000/0998125000000/09039068不是你所期望的吗?
    • 理想值应该是P(Xbar> 0.36) = P(Z> -2.909845) = 1 - P(Z 0.36) / M = 32000 for N = 36: 0.9984063,但你的答案非常接近,你做了什么?
    • 老实说我不知道​​哪个是 seet.seed (129)
    • 还要检查 Znmiu)/(sigmasqrt(n)),我认为应该是 (X - n*miu)/(sigma /sqrt(n))
    猜你喜欢
    • 2017-03-11
    • 2011-10-27
    • 2014-02-15
    • 2021-02-11
    • 1970-01-01
    • 1970-01-01
    • 2019-04-11
    • 1970-01-01
    • 2015-05-09
    相关资源
    最近更新 更多