Enumerate outcomes of Sampling without order, but with replacement

Draw k times from {1,2,..,n}, but return each drawn element -- which unique combinations are there?
208 Downloads
Updated Wed, 29 Feb 2012 17:21:55 +0000

View License

Given a set
S = {1,2,...,n},
nreplace(n,k) returns a matrix, each row of which represents a possible outcome of selecting k elements from S, while one element can be selected multiple times. See e.g. the Example at the bottom of http://en.wikibooks.org/wiki/Probability/Combinatorics#Partitions.
The implementation is recursive, using a nested function, so it will only run on Matlab Version 7 and upwards.

Cite As

Jonathan Epperl (2024). Enumerate outcomes of Sampling without order, but with replacement (https://www.mathworks.com/matlabcentral/fileexchange/35378-enumerate-outcomes-of-sampling-without-order-but-with-replacement), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0