BINOM calculates the binomial coefficient n!/((n-m)!*m!) CALL: y=binom(n,m); Example:% binom(5,2) % Should be 10.
01 function y=binom(n,m) 02 % BINOM calculates the binomial coefficient n!/((n-m)!*m!) 03 % 04 % CALL: y=binom(n,m); 05 % 06 % Example:% 07 % binom(5,2) % Should be 10. 08 09 % tested on: matlab 5.x 10 % History: 11 % by pab 17.11.98 12 if 1, 13 y=nchoosek(n,m); 14 else 15 y=exp(gammaln(n+1)-gammaln(n-m+1)-gammaln(m+1)); 16 end 17
Comments or corrections to the WAFO group