About Site Map Submit Contact Us Log in | Create an account
Create an account Log In
Average Rating
User Rating:
Visitors Rating:
My rating:

Write review
See full specifications

scripts default iconnsumk (Scripts) Publisher's description

Little more than syntactic sugar for nchoosek

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 second argument, a listing of them. As an alternative to downloading, just cut and paste the following:

m = nchoosek(k+n-1,n-1);
dividers = [zeros(m,1),nchoosek((1:(k+n-1))',n-1),ones(m,1)*(k+n)];
x = diff(dividers,1,2)-1;

It has been noted with some passion that this it is possible to achieve the same result using partitions.m, a more general function posted on Matlab Central. Indeed nsumk(n,k) returns the same result as sortrows(partitions(k, ones(1,n))). For small problems the latter is probably no more than 10x slower than using nchoosek. For large problems the performance of nsumk is substantially better (but only because we desire a special ordering).

These observations may be more relevant to others than this author, and no effort has been made to optimize nsumk (or for that matter nchoosek). See vchoosek.m for a faster .mex implementation of nchoosek.

System Requirements:

MATLAB 7.10 (2010a)
Program Release Status: Major Update
Program Install Support: Install and Uninstall

nsumk (Scripts) Tags:

Click on a tag to find related softwares

Is nsumk (Scripts) your software?

Manage your software

Most Popular

scripts default icon ASK, OOK, FSK, BPSK, QPSK, 8PSK modulation 1.1
ASK, OOK, FSK, BPSK, QPSK, 8PSK modulation contain several functions for digital modulation simulation
scripts default icon Simulink Communication Labs 1.1
Simulink Communication Labs allows you to learn communication systems in greater depth.
scripts default icon M-QAM modulation and demodulation 1.1
M-QAM modulation and demodulation is the QAM modulation and demodulation tech.
scripts default icon LZW Compression/Decompression 1.1
LZW Compression/Decompression - Updated LZW compressor and decompressor with reasonable performance
scripts default icon InSPIRE utility to plot a 2D displacement field (Scripts) 1.0
This program plots the deformation field (displace vectors) contained in vector.txt.