補足. 尤度比検定_1

$\gdef \vec#1{\boldsymbol{#1}} \\ \gdef \rank {\mathrm{rank}} \\ \gdef \det {\mathrm{det}} \\ \gdef \Bern {\mathrm{Bern}} \\ \gdef \Bin {\mathrm{Bin}} \\ \gdef \Mn {\mathrm{Mn}} \\ \gdef \Cov {\mathrm{Cov}} \\ \gdef \Po {\mathrm{Po}} \\ \gdef \HG {\mathrm{HG}} \\ \gdef \Geo {\mathrm{Geo}}\\ \gdef \N {\mathrm{N}} \\ \gdef \LN {\mathrm{LN}} \\ \gdef \U {\mathrm{U}} \\ \gdef \t {\mathrm{t}} \\ \gdef \F {\mathrm{F}} \\ \gdef \Exp {\mathrm{Exp}} \\ \gdef \Ga {\mathrm{Ga}} \\ \gdef \Be {\mathrm{Be}} \\ \gdef \NB {\mathrm{NB}}$

$$\begin{aligned} f_n(\vec x;p) &= \prod_{i=1}^n \{ p^{x_i} (1-p)^{1-x_i} \} \\[10px] \Rightarrow \log f_n(\vec x;p) &= (\sum_{i=1}^n x_i) \cdot \log p + (\sum_{i=1}^n (1-x_i)) \cdot \log (1-p) \end{aligned}$$


両辺を$p$で偏微分して、
$$\begin{aligned} \frac{\partial}{\partial p} \log f_n(\vec x;p) &= \frac{\sum_{i=1}^n x_i}{p}-\frac{\sum_{i=1}^n (1-x_i)}{1-p} \end{aligned}$$となるが、(上式)$=0$、と置いた時の$p$が$\hat{p}$なので、
$$\begin{aligned} \frac{\sum_{i=1}^n x_i}{\hat{p}}-\frac{\sum_{i=1}^n (1-x_i)}{1-\hat{p}} = 0 \\[10px] \Rightarrow \hat{p} = \frac{1}{n} \sum_{i=1}^n x_i \end{aligned}$$