Choose K elements from a vector - MEX: 100 times faster than NCHOOSEK
's NCHOOSEK, except that NCHOOSEK replies the number of combinations for a scalar V: VChooseK(-1, 1) replies [-1]: One element taken out of a set of length one. NCHOOSEK(-1, 1) fails at calculating
- 3.1K (All time)
- 3 (Last 30 days)
- 4.9 / 5
- Community
-
23 Dec 2009
- 3.3K (All time)
- 2 (Last 30 days)
- 5.0 / 5
- Community
-
4 Mar 2016
Random sample (without replacement) from unique permutations of a vector or row-perms of a matrix
routines are also included to provide faster solutions in special cases of permutation test: simple correlation (perms_m); one-sample t-test (signs_m); and two-sample t-test (nchoosek_m). See
- 1.5K (All time)
- 1 (Last 30 days)
- 5.0 / 5
- Community
-
21 Apr 2010
Performance of Differential Amplify-and-Forward Relaying in Multi-Node Wireless Communications
Performance of Differential Amplify-and-Forward Relaying in Multi-Node Wireless Communications
- 818 (All time)
- 5 (Last 30 days)
- 5.0 / 5
- Community
-
18 Aug 2014
A fast NCHOOSEK alternative for engineers who like fast NCHOOSEK alternatives
This code recursively generates K-subsets of an N-set.
. It is a recursive alternative to the NCHOOSEK command that is extremely fast (O(1)), at the expense of slightly more user interaction. (You do get something that NCHOOSEK does not give you forthis
- 425 (All time)
- 1 (Last 30 days)
- 3.5 / 5
- Community
-
27 Jan 2014
Variable Precision Integer Arithmetic
Arithmetic with integers of fully arbitrary size. Arrays and vectors of vpi numbers are supported.
large arguments, or large factorials, or convert binary numbers with thousands of digits to decimal (vpi) form.For example, the existing nchoosek function in matlab gets upset for even reasonably small
- 18.9K (All time)
- 14 (Last 30 days)
- 4.8 / 5
- Community
-
27 Jan 2015
nchoosek with enumerate selection. This function never build the full combination array in memory
1:chunksize;norepetition = false;while true if norepetition c = nchoosek_enum(n, k, i); else c = nchoosek_enum(n+k-1, k, i); c = c - (0:k-1); end for r=1:size(c,1) cr = c(r
- 13 (All time)
- 2 (Last 30 days)
- -- / 5
- Community
-
27 Apr 2021
Real-Time-Speech-Brain-Entrainment-Neurofeedback-Toolbox
EEG brain-computer interface system for providing real-time speech entrainment neurofeedback
- 740 (All time)
- 9 (Last 30 days)
- -- / 5
- Community
-
14 Apr 2021
- 876 (All time)
- 1 (Last 30 days)
- -- / 5
- Community
-
22 Jan 2008
- 24 (All time)
- 1 (Last 30 days)
- -- / 5
- Community
-
25 May 2024
Quick Jacobi polynomials for non-negative integer a,b
Quick calculation of Jacobi polynomials in case of non-negative integer parameters a,b
- 33 (All time)
- 1 (Last 30 days)
- 5.0 / 5
- Community
-
28 Jul 2021
Vectorized version of nchoosek function for multiple k's
- 35 (All time)
- 2 (Last 30 days)
- -- / 5
- Community
-
30 Jan 2017
- 1.1K (All time)
- 1 (Last 30 days)
- 5.0 / 5
- Community
-
27 Apr 2012
- 1.2K (All time)
- 1 (Last 30 days)
- 4.0 / 5
- Community
-
30 Dec 2022
- 326 (All time)
- 1 (Last 30 days)
- 5.0 / 5
- Community
-
16 Feb 2010
Obtain a single combination of N numbers taken K at a time.
comb = ONECOMB(N,K,M) returns the M-th combination of the sorted list of all combinations from NCHOOSEK. Makes use of a fast algorithm for the generation of a single combination.NCHOOSEK(1:4,3) = [ 1
- 985 (All time)
- 1 (Last 30 days)
- 5.0 / 5
- Community
-
22 Feb 2009
- 377 (All time)
- 1 (Last 30 days)
- -- / 5
- Community
-
4 Jan 2011
all combinations of two elements
NCHOOSE2 - all combinations of two elements Y = NCHOOSE2(X) returns all combinations of two elements of the array X. It is the fast, vectorized version of NCHOOSEK(X,2). X can be any type of array
- 2.7K (All time)
- 1 (Last 30 days)
- 5.0 / 5
- Community
-
28 Feb 2019
Estimating Time-varying Neural Interactions
Matlab code for estimating time-varying interactions of neurons from spike data.
- 606 (All time)
- 1 (Last 30 days)
- -- / 5
- Community
-
2 Jul 2012
NCHOOSEK with its complementary combinations
NCHOOSEKCOM Binomial coefficient or all combinations, and its complementWith one output argument, C = NCHOOSEKCOM (..) is the same as C = NCHOOSEK(..). For a vector V, C = NCHOOSEKCOM(V, K) returns a
- 33 (All time)
- 1 (Last 30 days)
- -- / 5
- Community
-
28 Apr 2019
COMBINATOR -combinations AND permutations
Returns 1 of 4 different samplings on the set 1:N, taken K at a time.
- 11.5K (All time)
- 3 (Last 30 days)
- 5.0 / 5
- Community
-
9 Sep 2010
Permutations with repetition, all or a subset
matrix % permn can be used generate a binary table, as in B = permn([0 1],5) NB Matrix sizes increases exponentially at rate (n^N)*N. See also perms, nchoosek allcomb
- 19.2K (All time)
- 14 (Last 30 days)
- 4.9 / 5
- Community
-
10 Jan 2019
Returns the number and listing of n-tuples of non-negative integers adding up to k.
Little more than syntactic sugar for nchoosek, this small but surprisingly controversial function returns the number of (ordered) n-tuples of non-negative integers adding up to k, and if supplied a
- 1.1K (All time)
- 3 (Last 30 days)
- 4.0 / 5
- Community
-
15 Aug 2010
All possible permutations of the elements of set N, taken K at a time, with repetition.
- 10.6K (All time)
- 2 (Last 30 days)
- 4.9 / 5
- Community
-
31 Aug 2012
All combinations of input (v4.2, apr 2018)
. See also nchoosek, perms, ndgrid and nchoose, combn, kthcombn (matlab Central FEX)
- 25.5K (All time)
- 12 (Last 30 days)
- 5.0 / 5
- Community
-
30 Apr 2018
Very simple function to generate a table of all possible binomial coefficients below a cut off
Uses a recursion relation to generate all the binomial coefficients nchoosek(n,k) for a range n<=nmax, k<= n. This is much faster than using nchoosek to make this table. The idea of this
- 231 (All time)
- 1 (Last 30 days)
- 5.0 / 5
- Community
-
17 Jan 2012
all combinations of the elements of a set
elements of S as being unique. One could use nchoose(UNIQUE(S)) to avoid that. - Loosely speaking, nchoose(S) collects all output of multiple calls to NCHOOSEK(S, K) where K is looping from 1 to
- 3.5K (All time)
- 1 (Last 30 days)
- 5.0 / 5
- Community
-
8 Feb 2019
all possible ordered permutations of M values in N positions
' 'XX' 'b' ; 'XX' 'a' 'b'} See also nchoosek, perms, randperm, true, false On the file Exchange: permn, PERMNK, permsk, allcomb, ballatsq, nones, nextpermpos
- 3.7K (All time)
- 2 (Last 30 days)
- 4.7 / 5
- Community
-
14 May 2019
Choose K elements from a vector with repetitions and without order [MEX]
- 1K (All time)
- 2 (Last 30 days)
- 5.0 / 5
- Community
-
5 Jan 2010
Choose K elements from a vector with repetitions and order [MEX]
- 1.3K (All time)
- 1 (Last 30 days)
- -- / 5
- Community
-
1 Jan 2010
Random sets of distinct permutations, combinations and subsets
without repetition (out of nchoosek(n, k) possible).Distinct random subsets (combinations without repetition) out of n elements (out of 2^n possible).Can force to include the "identity" or "null" element
- 73 (All time)
- 2 (Last 30 days)
- 5.0 / 5
- Community
-
29 Jun 2016
files for iterating over permutations, combinations, subsets and vectorized for/while loops
The NextVector toolbox is a collection of files useful for doing iterations over all permutations, combinations, subsets and tuples.This is useful when the results of perms or nchoosek are too large
- 1.7K (All time)
- 2 (Last 30 days)
- 5.0 / 5
- Community
-
11 Aug 2009
Computes coefficients powers for a multinomial expansion of the form (a_1+...+a_M)^N
nchoosek(N+M-1,N).'c' is a Kx1 vector of coeficients'p' is a KxM matrix of powers, with k^th row containing the powers p(k,1) through p(k,M).
- 229 (All time)
- 1 (Last 30 days)
- 5.0 / 5
- Community
-
19 Aug 2011
returns those subsets (= combinations of elements of a set) that fulfill a specific criterion
nchoosek, perms nchoose, permn, allcomb on the file Exchange
- 815 (All time)
- 1 (Last 30 days)
- 5.0 / 5
- Community
-
6 Feb 2018
Produces one comb/perm at a time. Both with/without repetition.
- 4.3K (All time)
- 2 (Last 30 days)
- -- / 5
- Community
-
17 Jun 2009
Fast unordered samples with or without repetition.
NMULTICHOOSEK(N,K) finds the number of multisets of length k on n symbols. NMULTICHOOSEK can take vector or scalar input.NMULTICHOOSEK(N,K,'single') is the same as NCHOOSEK (unordered samples WITHOUT
- 1.9K (All time)
- 2 (Last 30 days)
- -- / 5
- Community
-
17 Nov 2005
number of ways of choosing k objects from n objects
% This code does the same job of "nchoosek(n,k)" builtin code for % the number of ways of choosing k objects from n distinct objects.% The mathematical definition is C=n!/(n-k)!/k!% This code is
- 160 (All time)
- 1 (Last 30 days)
- -- / 5
- Community
-
1 Jul 2014
Fast and accurate N over K
times slower, less accurate nchoosek(n, k) 20 times slower, less accurate: nchoosek(61, 17) 536830054536826 (14 valid digits only) NoverK(61, 17) 536830054536825 The accuracy
- 26 (All time)
- 1 (Last 30 days)
- -- / 5
- Community
-
22 Feb 2022
Return a random subset of k elements of the set of n elements
A = RANDSUBSET(N, K) is equivalent toALLSUBSETS = NCHOOSEK(1:N,K);A = ALLSUBSETS(RANDI(NCHOOSEK(N,K)));% orA = RANDPERM(N);A = SORT(A(1:k)); This function can also be used to generate random sampling
- 403 (All time)
- 2 (Last 30 days)
- -- / 5
- Community
-
29 Jun 2010
Returns k random combinations of p unique integers between 1 and N.
. There are at most nchoosek(N,p) combinations of p unique integers between 1 and N, therefor k <= nchoosek(N,p).Example: The following code: N = 9; k = 3; p = 4; C = kcombsn(N,k,p);could return the
- 47 (All time)
- 1 (Last 30 days)
- -- / 5
- Community
-
13 Jan 2016
All combinations of N elements taken two at the time.
MATLAB function NCHOOSEK(dat,2) but much faster.
- 1.1K (All time)
- 2 (Last 30 days)
- -- / 5
- Community
-
29 May 2008
Given a set of N items, iterate over all the combinations of size R (R<N)
Given a set of N items, we want to do something with all possible subsets of that set which have size K. This method iterates over those subsets in a deterministic fashion. Unlike "nchoosek" (which
- 431 (All time)
- 1 (Last 30 days)
- -- / 5
- Community
-
3 Oct 2008
Choose K elements from a vector without repetitions and with order [MEX]
- 1.7K (All time)
- 2 (Last 30 days)
- -- / 5
- Community
-
17 Jan 2010
Find and return Binomial Coefficients (BCs) in a matrix up to N.
This function can return N choose K (K <= N) as well as a BC matrix up to N choose N.
lower-triangular Pascal matrix and does a simple lookup to get the desired BC. BINOMIND is much faster than NCHOOSEK at creating matrices of BCs if you set SPEED to TRUE and also has a basic integrity check to
- 191 (All time)
- 2 (Last 30 days)
- -- / 5
- Community
-
30 Dec 2011
Allows user to pause MATLAB simulation.
time.Useful if e.g. you are running a long simulation and suddenly decide you want to know how many five card poker hands are in a pack.Click the pause button, enter nchoosek(52,5) at the command window prompt
- 2.4K (All time)
- 1 (Last 30 days)
- 4.3 / 5
- Community
-
10 Oct 2006
Next (lexicographic) permutation of values
returns the permutations in sorted order. V = 1:3 ; % 3 distinct values -> 6 permutations W1 = perms(V) W2 = nextperm(V, 0:5) See also perms, nchoosek
- 271 (All time)
- 3 (Last 30 days)
- 5.0 / 5
- Community
-
16 Mar 2018
K-th combination(s) of elements
dec2bin(K-1,N)-'0' See also nchoosek, permsand combn, allcomb, nchoose on the File Exchange
- 283 (All time)
- 1 (Last 30 days)
- 5.0 / 5
- Community
-
17 Jan 2012
Calculates the rank (sequential ordinal) of nCk combinations
Example:Combs=nchoosek(1:5,3)Combs = 1 2 3 1 2 4 1 2 5 1 3 4 1 3 5 1 4 5 2 3 4 2 3 5 2 4 5
- 609 (All time)
- 1 (Last 30 days)
- -- / 5
- Community
-
19 Jan 2009
Compute the Maximum Points Value in Optimum triangular area (update:07-29-07)
optimization analysis with cyclic-permutation
main function as -nchoosek-. Plainly, If you selected more 100 point than solution time possible be few minute. This program's low-order-level of run-time not depent is my program's base-algorithm.for
- 1.3K (All time)
- 1 (Last 30 days)
- -- / 5
- Community
-
30 Jul 2007
All combinations of three elements.
NCHOOSE3 - all combinations of three elements Y = NCHOOSE3(X) returns all combinations of three elements of the array X. It is the fast, vectorized version of NCHOOSEK(X,3). X can be any type of
- 17 (All time)
- 1 (Last 30 days)
- -- / 5
- Community
-
12 Dec 2018
Combinatorial numbering rank and unrank
Translate between standard numbering and combinatorial numbering of n choose k.
The sequence of combinations defined by N-choose-k (no ordering, no replacement) form a sequence that can be lengthy. These routines provide a way to translate between this sequence and the standard
- 108 (All time)
- 1 (Last 30 days)
- -- / 5
- Community
-
13 Nov 2015
.
clc;close all;a=[-1,1,1,0;1,1,0,1];b=[1;2];c=[1,2,0,0];[m n]=size(a);nCm=nchoosek(n,m);pair=nchoosek(1:n,m);sol=[];for i=1:nCm y=zeros(n,1); B=a(:,pair(i,:)); x=B\b; if all(x>=0
- 0 (All time)
- 0 (Last 30 days)
- -- / 5
- Community
-
20 Feb 2023
the next combination of values in specific positions (extension of PERMPOS)
([0 1 0]) % c2 = [0 0 1], tf = true [c3, tf] = nextpermpos (c2) % c3 = [1 0 0], tf = false See also permpos (matlab File Exchange), nchoosek
- 242 (All time)
- 2 (Last 30 days)
- -- / 5
- Community
-
10 Oct 2012
Solves Chinese Math Game of 24
it found all possible solutions. For a deck of 13 cards, it turns out that there are nchoosek(16,4) four card combinations, or 1820. From the Wikipedia page, I saw that Cheng Chang published all
- 418 (All time)
- 1 (Last 30 days)
- -- / 5
- Community
-
24 Jan 2012
Control Loop for Cognitive Decision Making.
A control loop to drive a cognitive decision maker with in-mission learning. Project in "Cognitive EW: An AI Approach" by Haigh & Andrusenko
by memory and time (in addition to Adequacy)5. Add n-choose-k ablation trialsThe scenario driver corresponds to Algorithm 10.1, Figure 10.13,and Project 11.6.12 of the second edition, or Figure 10.2 of
- 22 (All time)
- 2 (Last 30 days)
- -- / 5
- Community
-
5 Aug 2025
.
variable[m,n]=size(A);if n>=mnv=nchoosek(n,m);t=nchoosek(1:n,m); % it forms pairs according to the value of m sol=[]; % it will store the solutionfor i=1:nv y=zeros(n,1); B=A(:,t(i
- 2 (All time)
- 1 (Last 30 days)
- -- / 5
- Community
-
20 Feb 2023
All permutations of K elements from an array (set)
K > N, P will be empty.See also perms, nchoosek, randperm, permute. permn, nchoose, nchoose2 (file Exchange)
- 69 (All time)
- 1 (Last 30 days)
- -- / 5
- Community
-
22 Apr 2019
pratheeb
1/(1 + 1i*z/zR) .* exp(-r.^2/w0^2./(1 + 1i*z/zR));w = w0 * sqrt(1 + z.^2/zR^2);R = sqrt(2)*r./w;% Lpl from OT toolbox Lpl = nchoosek(p+l,p) * ones(size(R)); % x = R(r, z).^2for m = 1:p Lpl = Lpl +
- 181 (All time)
- 1 (Last 30 days)
- -- / 5
- Community
-
24 May 2019
- 11.3K (All time)
- 73 (Last 30 days)
- 4.9 / 5
- Community
-
1 Aug 2024