63 results

VChooseK

Version 1.0.0.0

by Jan

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

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

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

Numerical computation with functions

Quick calculation of Jacobi polynomials in case of non-negative integer parameters a,b

nchoosek_enum

Version 1.0.1

by Bruno Luong

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

les m-fichiers de l'aide mémore Matlab seconde édition

nCk(n,k)

Version 1.0.0.0

by Eyal Ben-Hur

Vectorized version of nchoosek function for multiple k's

binomfactors

Version 1.0.0.0

by John D'Errico

Returns a factored form for very large binomial coefficients

ONECOMB

Version 1.0.0.0

by Darren Rowland

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

ChooseK

Version 1.3.0.0

by Bruno Luong

All pairs intersecting on k-1 tuples from all possible k-tuples of n objects

nchoose2

Version 3.2.0.1

by Jos (10584)

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

Matlab code for estimating time-varying interactions of neurons from spike data.

nchoosekcom

Version 1.0.1

by Jos (10584)

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

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

Returns 1 of 4 different samplings on the set 1:N, taken K at a time.

permn

Version 6.2.0.0

by Jos (10584)

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

nsumk

Version 1.7.0.0

by Peter Cotton

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

N_PERMUTE_K

Version 1.4.0.0

by Matt Fig

All possible permutations of the elements of set N, taken K at a time, with repetition.

allcomb(varargin)

Version 4.2.0.0

by Jos (10584)

All combinations of input (v4.2, apr 2018)

. See also nchoosek, perms, ndgrid and nchoose, combn, kthcombn (matlab Central FEX)

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

nchoose

Version 3.0

by Jos (10584)

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

PERMPOS

Version 3.0.1

by Jos (10584)

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

VChooseKR

Version 1.0.0.0

by Jan

Choose K elements from a vector with repetitions and without order [MEX]

VChooseKRO

Version 1.0.0.0

by Jan

Choose K elements from a vector with repetitions and order [MEX]

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

multinom

Version 1.0.0.0

by Damith Senaratne

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).

returns those subsets (= combinations of elements of a set) that fulfill a specific criterion

nchoosek, perms nchoose, permn, allcomb on the file Exchange

Produces one comb/perm at a time. Both with/without repetition.

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

Choosenk.m

Version 1.0.0.0

by Faryad

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

NoverK

Version 1.2.1

by Jan

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

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

RANDSUBSET

Version 1.2.0.0

by Bruno Luong

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

KCOMBSN

Version 1.2.0.0

by Eric Schols

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

nCtwo

Version 1.0.0.0

by Simone Scaringi

All combinations of N elements taken two at the time.

MATLAB function NCHOOSEK(dat,2) but much faster.

nextcombi

Version 1.0.0.0

by Dan Stowell

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

VChooseKO

Version 1.0.0.0

by Jan

Choose K elements from a vector without repetitions and with order [MEX]

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

pauseButton

Version 1.0.0.0

by Murphy O'Brien

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

nextperm(V, K)

Version 3.0.0.0

by Jos (10584)

Next (lexicographic) permutation of values

returns the permutations in sorted order. V = 1:3 ; % 3 distinct values -&gt; 6 permutations W1 = perms(V) W2 = nextperm(V, 0:5) See also perms, nchoosek

KTHCOMBN

Version 1.1.0.0

by Jos (10584)

K-th combination(s) of elements

dec2bin(K-1,N)-'0' See also nchoosek, permsand combn, allcomb, nchoose on the File Exchange

Combin2Rank

Version 1.1.0.0

by Paulo Fonte

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

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 +

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

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

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

bfs_202

Version 1.0.0

by Rohit

.

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&gt;=0

ot-lab-bfs

Version 1.0.0

by Akshay

code

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,:)); %det zero x=B\b; if

Archimedes wrote 3 1/7 > pi > 3 10/71. This is how he did it.

NEXTPERMPOS

Version 1.0.0.0

by Jos (10584)

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

24 Game Solver

Version 1.1.0.0

by Raj Sodhi

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

Binomial coefficients / Pascal Triangle elements for / N choose K look-up table (LUT) with no numerical errors for 0 <= N <=1029.

loss of numerical precision in 'double' typesb = binomial(60, 30);err = str2double(b) - nchoosek(60, 30);b = binomial(65, 35);res = sym(b) - str2double(b);err = 16res = -32

bfs2_202

Version 1.0.0

by Rohit

.

variable[m,n]=size(A);if n&gt;=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

permsk

Version 1.1

by Jos (10584)

All permutations of K elements from an array (set)

K &gt; N, P will be empty.See also perms, nchoosek, randperm, permute. permn, nchoose, nchoose2 (file Exchange)

choose.m

Version 1.1.0.0

by Phillip M. Feldman

compute number of ways of choosing m objects from n distinct objects

susceptible to overflow, and is faster than Matlab's builtin nchoosek function.

Flexible Statistics Data Analysis Toolbox

Performance of Differential Amplify-and-Forward Relaying in Multi-Node Wireless Communications

optimization analysis with cyclic-permutation

run-time is depend matlab main function as -nchoosek-. Plainly, If you selected more 50 point than solution time possible be few minute. This program's low-order-level of run-time not depent is my program

GPstuff

Version 4.6.0.0

by Aki Vehtari

Gaussian process models for Bayesian analysis

Load more