Home > wafo > misc > binom.m

binom

PURPOSE ^

calculates the binomial coefficient n!/((n-m)!*m!)

SYNOPSIS ^

y=binom(n,m)

DESCRIPTION ^

  BINOM calculates the binomial coefficient n!/((n-m)!*m!)
 
  CALL:  y=binom(n,m);
 
  Example:%  
     binom(5,2)    % Should be 10.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group


Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003