|Tools & Models| |Harvest Project|
[Top] [Contents] [Prev] [Next]

Appendix B. Computer algorithm for generating hypergeometric random variable.

Let

N : population size;

M : number in subpopulation;

p : proportion of population that is from subpopulation (M/N);

n : sample size;

X : random number (0 £ X < 1);

m : hypergeometric random value (output of routine).

Step 1. Compute the upper and lower bounds for the random variable:

Step 2. Use the lower bound as a seed value and compute the density using Stirling's Approximation.


By Stirling's Approximation,

where


Step 3. Set the distribution equal to the density.

Step 4. Loop to locate hypergeometric random variable.

While ((m < Upper Bound) and (Dist < X))
m = m + 1
Den = (Den) ((pN - m + 1)(n - m + 1))/(m(N - pN - n + m))
Dist = Dist + Den
End

[Top] [Contents] [Prev] [Next]
Selective Fishery Simulation Model Specifications