Find and return Binomial Coefficients (BCs) in a matrix up to N.

This function can return N choose K (K <= N) as well as a BC matrix up to N choose N.
188 Downloads
Updated 30 Dec 2011

View License

The function BINOMIND(N,K,SPEED) does not use loops (apart from a redundant check) or division nor indeed factorials to generate the Binomial Coefficients (BCs). It simply constructs the lower-triangular Pascal matrix and does a simple lookup to get the desired BC.

BINOMIND is much faster than NCHOOSEK at creating matrices of BCs if you set SPEED to TRUE and also has a basic integrity check to compare it with nchoosek. It can return 3 lots of data: comb,binTable, errorRate but you can just use it to find combinations by default.

Cite As

Bruce Raine (2024). Find and return Binomial Coefficients (BCs) in a matrix up to N. (https://www.mathworks.com/matlabcentral/fileexchange/34375-find-and-return-binomial-coefficients-bcs-in-a-matrix-up-to-n), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2011a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Discrete Math in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.2.0.0

Fixed one bug in the 'if nargin' statement on line 43 and improved 'if k > n' error message on line 49.

1.1.0.0

I added more input parameter checking, an extra input parameter, SPEED as well as a warning message for COMB values above a predefined tolerance limit. I also improved the documentation of the function.

1.0.0.0