The algorithm for finding optimal values of the sample size n and decision rule d for the Hypergeometric model for a population size N proceeds as follows:

- Start with n=1, d=0
- Calculate the rounded upper threshold number, H = round(p_up*N)
- Calculate the rounded lower threshold number, L = round(p_low*N)
- Calculate alpha, which is the CDF of the hypergeometric distribution: alpha=CDF(d, N, H, n)
- Calculate beta, which is 1 â€“ CDF(d, N, L, n)
- If alpha <= alpha_threshold and beta <= beta_threshold then the solution is (n, d), otherwise continue
- If d=n then increase n by 1 and set d=0. Otherwise increase d by 1
- Return to step 2

The procedure for the Binomial model is similar, with the Binomial CDF used in place of the Hypergeometric. The Binomial CDF takes three parameters: CDF(d, N, p), where p is either the upper threshold probability p_up (in step 2) or the lower threshold p_low (in step 3)

Both of these models assume a random sample from the supervision area, and the Binomial model assumes that the probability of sampling the same person twice is very small.