randpermquick

A quick alternative to MATLAB's randperm.
716 Downloads
Updated 6 Jun 2008

View License

You can generate random permutations using MATLAB's randperm function. Unfortunately, thius function is quite inefficient since it is implemented by sorting a list of random numbers. This requires time O(n * log(n)).

Using the Knuth shuffle algorithm this operation only takes time O(n). This package implements the Knuth shuffle.

Usage: Simply use randpermquick(n) instead of randperm(n).

Note that the file randpermquick_helper.c has to be compiled before randpermquick can be used.

Cite As

Joachim Selke (2024). randpermquick (https://www.mathworks.com/matlabcentral/fileexchange/20192-randpermquick), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2008a
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