I am calculating the probability of rejecting a one-tailed hypothesis test for inequality of two proportions $p_1$ and $p_2$ (i.e., power) using $H_o: p_2 \leq p_1$ vs. the alternative $H_a: p_2 > p_1$ using the exact formulation
$$ Prob=\sum_{i=0}^m \sum_{j=0}^n \binom{m}{i} \binom{n}{j} p_1^i \cdot (1 - p_1)^{m - i} \cdot p_2^j \cdot (1 - p_2)^{n - j} \cdot I(T>z_{1-\alpha}), $$
where $T = \frac{ p_j - p_i}{\sqrt{\bar{p} (1 - \bar{p})}\sqrt{\frac{1}{m}+\frac{1}{n}}}$, $p_i = i / m$, $p_j = j / n$, $\bar{p} = (i + j) / (m + n)$, and typical values of $m$ and $n$ are e.g. $80$ for my use case. $I()$ is a boolean indicator function. The binomial coefficient values $\binom{m}{i}$ take on very large integer values that are $\gg 10^{308}$ - the limit of double precision memory storage for most compilers. Analogously, the probabilities $p_1^i \cdot (1 - p_1)^{m - i} \cdot p_2^j \cdot (1 - p_2)^{n - j}$ can also be e.g. $\ll 10^{-308}$.
Are there any tricks for representing very small probabilities using large integers, or some reliable algorithm that would enable me to perform such multiplications. The limiting issue is that there doesn't seem to be one or more fast methods for memory representation of a real value with $\gg 308$ digit precision.
long doublecan store values in excess of $10^4000$ in many cases (it does depend on the compiler etc). – psmears Jun 05 '24 at 11:45