In [1]:
alpha <- 0.05
n <- 10000
rate <- c(968, 1026, 1021, 975, 1012, 1046, 1021, 969, 948, 1014)
df <- data.frame(Ziffer=0:9, Häufigkeit=rate)
In [2]:
nc <- 10
p_hat = 1/nc
n_p = n * p_hat
chisq_comp = (df$Häufigkeit - n_p)^2 / n_p
df <- data.frame(df, p=p_hat, n_p=n_p, chisq_comp=chisq_comp)
df
Out[2]:
In [3]:
Q <- sum(chisq_comp)
Q
Out[3]:
In [4]:
dof <- nc-1
chi <- qchisq(1-alpha, dof)
chi
Out[4]:
$Q \ngtr \chi \implies$ H0 wird nicht verworfen
In [5]:
pi <- scan("pi10000.txt")
In [6]:
chisq.test(table(pi), p=rep(0.1, 10))
Out[6]: