【问题标题】:Statistics - Standard Deviation of test statistic # of heads - # of tails统计 - 测试统计的标准偏差 # 正面 - # 反面
【发布时间】:2017-04-30 11:34:17
【问题描述】:
我有一个关于以下问题的问题
N 是编号。抛硬币
H是编号。获得的人头
T 是编号。获得的尾巴
Q = H-T
N = 100
H = 63
T = 37
Q = 26
这是证明硬币没有偏见的重要证据吗?
q 的标准差是多少?
谢谢!
【问题讨论】:
标签:
r
statistics
coin-flipping
【解决方案1】:
对于以正面概率为 p 的硬币进行 n 次试验,差值 Y=(H-T) 是一个随机变量,均值 = n (2 p - 1),方差 = 4 n p (1-p)。
以下数值模拟有助于更好地理解问题。
n <- 100
reps <- 100000
p <- 0.5
set.seed(4321)
y <- matrix(0,reps)
for (k in 1:reps) {
x <- rbinom(n, 1, p)
Heads <- sum(x)
Tails <- n - Heads
y[k] <- Heads-Tails
}
mean(y)
[1] 0.01198
n*(2*p-1)
[1] 0
var(y)
[,1]
[1,] 100.2223
4*n*p*(1-p)
[1] 100
hist(y, breaks=50, main="", freq=F)
curve(dnorm(x,mean=n*(2*p-1),sd=sqrt(4*n*p*(1-p))),-40,40,
add=T, lwd=2, col="red")
【解决方案2】:
如果您一开始就假设硬币有偏见,那么您需要一个 prob(head) 值来测试硬币是否无偏见。
根据您提供的数据,您可以进行二项式检验,看看硬币是否有偏差。
n <- 100
h <- 63
p <- 0.5
binom.test(h, n, p, alternative = "greater")
Exact binomial test
data: h and n
number of successes = 63, number of trials = 100,
p-value = 0.006016
alternative hypothesis: true probability of success is greater than 0.5
95 percent confidence interval:
0.5434341 1.0000000
sample estimates:
probability of success
0.63
p 值为 0.6%,这表明我们拒绝原假设而支持替代假设。即我们认为硬币是有偏见的。
[0.54, 1] 的 95% 置信区间进一步证明硬币存在偏差,因为它表明 P(H) > 0.5