Unofficial tutorial, use at your own risk
which means $$ P(\text{reject }H_0 | H_0 \text{ is true}) = \alpha $$
If $X$ is a random variable describing number of boys in a population, then assuming $H_0$ is true $$ Pr(X = k | H_0) = Pr(X = k | p_0 = 0.5) = \left(\frac{N}{k}\right)p_0^k (1-p_0)^{N-k} $$
Wald statistic has form $$ Z_W = (\hat{p} - p_0) \sqrt{\mathcal{I(\hat{p})}} \sim N(0,1). $$
After substitution $\hat{p} = \frac{x}{N}$ and $I(\hat{p}) = \frac{N^3}{X (N - X)}$ we get $$ Z_W = (\frac{X}{N} - p_0) \sqrt{\frac{N^3}{X (N - X)}}. $$
Note that since $X$ is still a random variable, so $Z_W$ is a random variable too and $Z_W \sim N(0,1)$. Let's get its realization using our data $x=534$ and $N=1000$ $$ z_W = (\frac{x}{N} - p_0) \sqrt{\frac{N^3}{x (N - x)}} = (0.534 - 0.5) \sqrt{\frac{1000^3}{534\cdot466}} = 2.155 $$
Critical region of $N(0,1)$ is $$ \mathcal{W} = (-\infty, u_{1-\alpha/2}) \cup (u_{\alpha/2}, \infty) = (-\infty, -1.96) \cup (1.96, \infty), $$ where $u_p$ is $1 - p$ quantile of standard normal distribution $N(0,1)$.
Using the fact that $Z_W \sim N(0,1)$ $$ \text{p-value} = 2\min(Pr(Z_W > z_W), Pr(Z_W < z_W)) = 2\min(0.0123, 0.89) $$
Wald confidence interval $$ (d_W, h_W) = \left(\hat{p} - u_{\alpha/2} \frac{1}{\sqrt{\mathcal{I(\hat{p})}}}, \hat{p} + u_{\alpha/2} \frac{1}{\sqrt{\mathcal{I(\hat{p})}}} \right) $$ after substitution $$ (d_W, h_W) = \left(\frac{x}{N} - u_{\alpha/2} \sqrt{\frac{x (N - x)}{N^3}}, \frac{x}{N} + u_{\alpha/2} \sqrt{\frac{x (N - x)}{N^3}} \right) $$ using $x=534$ and $N = 1000$ $$ (d_W, h_W) = \left(0.534 - 1.96 \cdot 0.0158, 0.534 + 1.96 \cdot 0.0158 \right) = (0.503, 0.565) $$
We are rejecting null hypothesis $p_0 = 0.5$ because
Likelihood statistic $$ Z_{LR} = -2(l(p_0|X) - l(\hat{p}|X)) \sim \chi_1^2 $$ We know that log-likelihood of a binomial distribution is $$ l(p|x) = x \ln p + (N - x) \ln(1-p). $$
Critical region of $\chi_1^2$ is $$ \mathcal{W} = (\chi_1^2(\alpha), \infty) $$ Let's use the realization $x = 534$ of $X$ to get statistics realization. Let's start with $$ l(p_0|x) = x \ln 0.5 + (N - x) \ln(1-0.5) $$ $$ l(\hat{p}|x) = x \ln 0.534 + (N - x) \ln(1-0.534) $$ then $$ z_{LR} = -2(l(p_0|X) - l(\hat{p}|X)) = 4.6275 $$
Using the fact that $Z_{LR} \sim \chi_1^2$ $$ \text{p-value} = Pr(Z_{LR} > z_{LR}) = 0.031 $$
Confidence is
$$
\mathcal{CS}_{1-\alpha} = \{p: -2(l(p|X) - l(\hat{p}|X)) < \chi_1^2(\alpha)\} = \{p: -2(l(p|X) - l(\hat{p}|X))) - \chi_1^2(\alpha) < 0\}
$$
Since inequality $l(\hat{p}|X)) - \frac{1}{2} \chi_1^2(\alpha)$ has no closed-form solution, we'll need to use numerical methods to find upper and lower confidence interval. (Use uniroot
function in R)
We are rejecting null hypothesis $p_0 = 0.5$ because