訊息

English

1. x 的樣本平均值 $\bar{x}$ 為何？

2. x 的樣本變異數 $S^2$ 為何？

3. x 母體平均值 $\mu$ 的 95% 信賴區間範圍為何？

mean.range = function(x, alpha=0.05, sigma) {
n = length(x) # n = 樣本數
mx = mean(x) # mx 即為平均值 mu 的點估計
r1 = qnorm(alpha/2) # 信賴區間，下半截掉 alpha/2
r2 = qnorm(1-alpha/2) # 信賴區間，上半截掉 alpha/2
L1 = mx+r1*sigma/sqrt(n) # 信賴區間下限
L2 = mx+r2*sigma/sqrt(n) # 信賴區間上限
range = c(L1, mx, L2) # 信賴區間
}

> x = c(3, 2, 1, 1, 2, 4, 1, 1, 6, 2, 1, 5, 5, 5, 5, 2, 2, 4, 2, 3)
> x
[1] 3 2 1 1 2 4 1 1 6 2 1 5 5 5 5 2 2 4 2 3
> mean(x)
[1] 2.85
> var(x)
[1] 2.765789
> r1 = mean.range(x, sigma=sqrt(2.92))
> r1
[1] 2.101099 2.850000 3.598901


1. x 的樣本平均值 $\bar{x}$ 為何？

2. x 的樣本變異數 $S^2$ 為何？

3. x 母體平均值 $\mu$ 的 95% 信賴區間範圍為何？

> x
[1] 8.934661 3.234151 5.063758 5.322139 3.611042 6.176047 7.596522 5.774294
[9] 2.017229 2.921471 7.550340 6.090995 7.824173 3.450554 1.985519 8.763690
[17] 6.828349 7.164586 2.160137 5.247192 5.045215 2.140142 6.033718 5.604483


> x = c(8.934661, 3.234151, 5.063758, 5.322139, 3.611042, 6.176047, 7.596522,
5.774294, 2.017229, 2.921471, 7.550340, 6.090995, 7.824173, 3.450554, 1.985519,
8.763690,6.828349, 7.164586, 2.160137, 5.247192, 5.045215, 2.140142, 6.033718, 5.604483)
> x
[1] 8.934661 3.234151 5.063758 5.322139 3.611042 6.176047 7.596522 5.774294
[9] 2.017229 2.921471 7.550340 6.090995 7.824173 3.450554 1.985519 8.763690
[17] 6.828349 7.164586 2.160137 5.247192 5.045215 2.140142 6.033718 5.604483
> mean(x)
[1] 5.272517
> var(x)
[1] 4.690823
> r1 = mean.range(x, sigma=sqrt(5.4))
> r1
[1] 4.342824 5.272517 6.202210
>