Where \(g\) is the observed proportion, \(e\) is the expected proportion, \(s_p\) is the estimated Standard Error of the observed proportion, and \(n\) is the sample size,
\[\begin{align} z = \frac{g - e}{s_p} \end{align},\]
where \(p = 2(1-\Phi(|z|))\) if \(g \ne e \) and NaN otherwise.