Combinations without overflow

The use of the factorial function in evaluating nCr = n!/((n-r)!*r!) has overflow problems when n>170 on a 64-bit machine.
11 download
Aggiornato 26 gen 2020

Visualizza la licenza

The use of the factorial function in computing nPr = n!/(n-r)! or in computing nCr = n!/((n-r)!*r!) has overflow problems when n>170 on a 64-bit machine.
These two functions: Perm(n,r) and Comb(n,r) avoid the overflow problem.
nPr is defined as Perm(n,r) and nCr is defined as Comb(n,r).

Example:
If n=171, factorial(n) = Inf on a 64-bit machine.
Therefore, neither P(171,15) nor C(171,15) can be evaluated directly.
Perm(171,15) = 1.6611e33, and
Comb(171,15) = 1.2703e21.
Likewise,
Perm(1000,49) = 3.0256e+146, and
Comb(171,15) = 4.9740e+83.

These two functions are useful in predicting the outcomes of Bernoulli experiments that utilize the binomial distribution.

Cita come

Lawrence Agbezuge (2024). Combinations without overflow (https://www.mathworks.com/matlabcentral/fileexchange/74034-combinations-without-overflow), MATLAB Central File Exchange. Recuperato .

Compatibilità della release di MATLAB
Creato con R2019b
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux
Tag Aggiungi tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versione Pubblicato Note della release
1.0.0