Home > voicebox > choosrnk.m

# choosrnk

## PURPOSE

CHOOSRNK All choices of K elements taken from 1:N with replacement. [X]=(N,K)

## SYNOPSIS

function x=choosrnk(n,k)

## DESCRIPTION

```CHOOSRNK All choices of K elements taken from 1:N with replacement. [X]=(N,K)
The output X is a matrix of size ((N+K-1)!/(K!*(N-1)!),K) where each row
contains a choice of K elements taken from 1:N with duplications allowed.
The rows of X are in lexically sorted order.

To choose from the elements of an arbitrary vector V use
V(CHOOSRNK(LENGTH(V),K)).```

## CROSS-REFERENCE INFORMATION

This function calls:
• choosenk CHOOSENK All choices of K elements taken from 1:N [X]=(N,K)
This function is called by:

## SOURCE CODE

```0001 function x=choosrnk(n,k)
0002 %CHOOSRNK All choices of K elements taken from 1:N with replacement. [X]=(N,K)
0003 % The output X is a matrix of size ((N+K-1)!/(K!*(N-1)!),K) where each row
0004 % contains a choice of K elements taken from 1:N with duplications allowed.
0005 % The rows of X are in lexically sorted order.
0006 %
0007 % To choose from the elements of an arbitrary vector V use
0008 % V(CHOOSRNK(LENGTH(V),K)).
0009
0010 %   Copyright (c) 1998 Mike Brookes,  mike.brookes@ic.ac.uk
0011 %      Version: \$Id: choosrnk.m 713 2011-10-16 14:45:43Z dmb \$
0012 %
0013 %   VOICEBOX is a MATLAB toolbox for speech processing.
0015 %
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 %   This program is free software; you can redistribute it and/or modify
0019 %   the Free Software Foundation; either version 2 of the License, or
0020 %   (at your option) any later version.
0021 %
0022 %   This program is distributed in the hope that it will be useful,
0023 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0024 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0025 %   GNU General Public License for more details.
0026 %
0027 %   You can obtain a copy of the GNU General Public License from
0028 %   http://www.gnu.org/copyleft/gpl.html or by writing to
0029 %   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
0030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0031 x=choosenk(n+k-1,k);
0032 x=x-repmat(0:k-1,size(x,1),1);```

Generated on Mon 06-Aug-2018 14:48:32 by m2html © 2003