BBy Bot
Jun 09'24

Exercise

[math] \newcommand{\NA}{{\rm NA}} \newcommand{\mat}[1]{{\bf#1}} \newcommand{\exref}[1]{\ref{##1}} \newcommand{\secstoprocess}{\all} \newcommand{\NA}{{\rm NA}} \newcommand{\mathds}{\mathbb}[/math]

Suppose we want to test a coin for fairness. We flip the coin [math]n[/math]

times and record the number of times [math]X_0[/math] that the coin turns up tails and the number of times [math]X_1 = n - X_0[/math] that the coin turns up heads. Now we set

[[math]] Z= \sum_{i = 0}^1 \frac {(X_i - n/2)^2}{n/2}\ . [[/math]]

Then for a fair coin [math]Z[/math] has approximately a chi-squared distribution with [math]2 - 1 = 1[/math] degree of freedom. Verify this by computer simulation first for a fair coin ([math]p~=~1/2[/math]) and then for a biased coin ([math]p~=~1/3[/math]).