# 17.8.6.2 Algorithm (PSS: Two-Proportion Test)

### Power

One-sided power:$H_0:p_1\ge p_2$

$Power =F(\frac{-(p_2-p_1)-z_{\alpha }\sqrt{\frac{(2p_c(1-p_c)}{n} }}{\sqrt{\frac{p_2(1-p_2)}{n}+\frac{p_1(1-p_1)}{n}}})$

One-sided power:$H_0:p_1\le p_2$

$Power =1-F(\frac{-(p_2-p_1)+z_{\alpha }\sqrt{\frac{(2p_c(1-p_c)}{n} }}{\sqrt{\frac{p_2(1-p_2)}{n}+\frac{p_1(1-p_1)}{n}}})$

Two-sided power $H_0: p_1=p_2\!$

$Power =1-F(\frac{-(p_2-p_1)+z_{\frac{\alpha}{2} }\sqrt{\frac{(2p_c(1-p_c)}{n} }}{\sqrt{\frac{p_2(1-p_2)}{n}+\frac{p_1(1-p_1)}{n}}})+F(\frac{-(p_2-p_1)-z_{\frac{\alpha}{2}}\sqrt{\frac{(2p_c(1-p_c)}{n} }}{\sqrt{\frac{p_2(1-p_2)}{n}+\frac{p_1(1-p_1)}{n}}})$

$n$: The sample size of each group

$p_1$:The proportion of 1st population

$p_2$:The proportion of 2nd population

$p_c =\frac{p_{1}+p_{2}}{2}$

$z_{\alpha }$: The $\alpha$-level upper critical value of Normal distribution

$z_{\frac{\alpha}{2} }$: The $\frac{\alpha}{2}$-level two-side critical value of Normal distribution

$F$:The cumulative distribution function of the standard normal distribution

### Sample Size

Origin uses an iterative algorithm with the power equation. At each iteration,the power for a trial sample size are evaluated and iteration stops when the power evaluated reaches the values which corresponding to an integer sample size, and which is nearest to, yet greater than, the target value.