Using the Log Gamma Function    Model: EZCOUNT

The factorial function is used in many probability computations. Un­fortunately, the factorial function can generate some very large numbers that can exceed the fixed word size of most computers. A common way around this is to use the Log Gamma function (@LGM), which returns the logarithm of the factorial function. In the following model, we use @LGM to compute the number of possible poker hands.

MODEL:

! This model computes the number of ways of selecting

 5 objects from a set of 52 objects;

! This is expressed by 52! / (5! * 47!). The actual

 computation uses the log-gamma function;

       WAYS = @EXP( @LGM( 53) - @LGM( 6) - @LGM( 48));

! Note that the arguments of the @LGM functions are

 one greater than the corresponding arguments of the

 factorial functions, due to the definition of the

 Gamma function;

END

Model: EZCOUNT