Next: blockdmat() Up: Mathematical Macros Help File Previous: bfs()   Contents


binom(n,k), REAL n and k with non negative elements.  If both are non-
  scalars, they must have the same dimensions

Keywords: binomial coefficients, integers
binom(n,k), where n >= 0 and k >= 0 are REAL scalars with n >= k returns
a binomial coefficient.  n and k need not be integers, but when they are
binom(n,k) returns n!/(k!*(n-k)!) as an exact integer.  Otherwise it
returns gamma(n+1)/(gamma(k+1)*gamma(n-k+1)), where gamma(x) is the
Gamma function.

When just one of n and k is a scalar, binom(n,k) returns a REAL vector,
matrix or array consisting of binomial coefficients computed from the
scalar and each of the elements of the other argument.

When neither n or k is a scalar, both must have exactly the same
dimensions and the result is an array with the same dimesions
consisting of of binomial coefficients computed from corresponding
elements of n and k.

  Cmd> binom(4,run(0,4)) # vector(binom(4,0),...,binom(4,4))
  (1)          1          4          6          4          1

  Cmd> binom(run(3,7),3) # vector(binom(3,3),...,binom(7,3))
  (1)          1          4         10         20         35

  Cmd> binom(run(3,7),run(0,4)) # vector(binom(3,0),...,binom(7,4))
  (1)          1          4         10         20         35

See also lgamma().

Gary Oehlert 2003-01-15