0
我正在用语言[R]生成一个M = 32000平均值的样本,每个平均值通过平均36个独立值随机变量连续均匀分布(0,1)如下产生:[R]中的中心极限定理
sampleA<-1:32000
for (i in 1:32000){
MuestraAUnif<- runif(36)
sampleA[i]<-mean(MuestraAUnif)
}
对于样品生成提问计算观察到的平均比L = 0.32 4 * 1 /大100的相对频率,并将其与概率(用“Central limit theorem”近似)的平均比较N值大于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)。我在做我的执行有问题吗?请原谅我的英语。
我已经做了,是我的错拷贝,但仍然无法正常工作,或不告诉我,我想 – franvergara66 2012-01-30 02:59:37
我使用seet.seed结果( 129)并得到:sum(sampleA> 0.3599999999999999866773)/ M = 32000.00000000000000000 N = 36.0000000000000000000:0.998125000000000039968。不是你所期望的? – aatrujillob 2012-01-30 03:09:10
对于N = 36,理想值应该是 P(Xbar> 0.36)= P(Z> -2.909845)= 1 -P(Z <-2.909845)= 0.998192 总和(样品a> 0.36)/ M = 32000 :0.9984063,但你的答案非常接近,你做了什么? – franvergara66 2012-01-30 03:18:52