Home > freetb4matlab > specfun > nchoosek.m

nchoosek

PURPOSE ^

%

SYNOPSIS ^

function A = nchoosek (v, k)

DESCRIPTION ^

% -*- texinfo -*-
% @deftypefn {Function File} {@var{c} =} nchoosek (@var{n}, @var{k})
%
% Compute the binomial coefficient or all combinations of @var{n}.
% If @var{n} is a scalar then, calculate the binomial coefficient
% of @var{n} and @var{k}, defined as
%
% @iftex
% @tex
% $$
%  {n \choose k} = {n (n-1) (n-2) \cdots (n-k+1) \over k~}
%                = {n~ \over k~ (n-k)~}
% $$
% @end tex
% @end iftex
% @ifnottex
%
% @example
% @group
%  /   ...
%  | n |    n (n-1) (n-2) @dots{} (n-k+1)       n~
%  |   |  = ------------------------- =  ---------
%  | k |               k~                k~ (n-k)~
%  \   /
% @end group
% @end example
% @end ifnottex
%
% If @var{n} is a vector generate all combinations of the elements
% of @var{n}, taken @var{k} at a time, one row per combination.  The 
% resulting @var{c} has size @code{[nchoosek (length (@var{n}), 
% @var{k}), @var{k}]}.
%
% @code{nchoosek} works only for nonnegative integer arguments; use
% @code{bincoeff} for non-integer scalar arguments and for using vector
% arguments to compute many coefficients at once.
%
% @seealso{bincoeff}
% @end deftypefn

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:
Generated on Sat 16-May-2009 00:04:49 by m2html © 2003