Binomial Coefficients

Computes an array of binomial coefficients, with options to balance speed and accuracy.

Vous suivez désormais cette soumission

Purpose
This code is a simple utility that computes binomial coefficients C_{ n , k } for 0 <= n <= n_max and for 0 <= k <= k_max, where n_max and k_max are function inputs, with options to balance speed and accuracy.
Use Case
Its use case is to replace looping through individual calls to Matlab's nchoosek.
Notes
  • The file binoms.m is the main function, while the file binoms__demo.mlx demonstrates an example of using the function.
  • The user can decide how to balance speed and accuracy of the computation (see the demo for examples).
  • Compared to the version '05 Jun 2026', this code should be faster and more accurate when used with any calc_type except 'safe' (in which case this code may be much slower).
  • Use of the 'safe' option for the input calc_type may invoke Matlab's Symbolic Math Toolbox, depending on the values of the inputs n_max and k_max.
  • Changes to this version were inspired by the comment from the author of [1] on the 'Discussions' section of this project.
References
[1] J. Simon, https://www.mathworks.com/matlabcentral/fileexchange/100174-noverk

Citation pour cette source

Nick Lorenzo (2026). Binomial Coefficients (https://fr.mathworks.com/matlabcentral/fileexchange/184038-binomial-coefficients), MATLAB Central File Exchange. Extrait(e) le .

Remerciements

A inspiré : Incomplete (Partial) Bell Polynomials

Informations générales

Compatibilité avec les versions de MATLAB

  • Compatible avec toutes les versions

Plateformes compatibles

  • Windows
  • macOS
  • Linux
Version Publié le Notes de version Action
2.0.0

Completely overhauled code to increase accuracy and speed.

1.0.1

Added binoms__demo.mlx to provide an example.

1.0.0