rand_unique_pairs(N​, pair_num, ordered, self_pair)

Version 1.2.0.0 (1.64 KB) by Yifan Gu
This function randomly generates unique integer number pairs, either ordered or unordered.
48 Downloads
Updated Mon, 13 Mar 2017 02:53:28 +0000

View License

This function could be handy for sampling pair-wise correlation from a large number of variables.
Input arguments:
N: defines the range of the numbers (from 1 to N)
pair_num: the number of pairs
ordered: 1 for ordered pairs and 0 for unordered. The default is 0.
self_pair: 1 for allowing self-pair (e.g, 3-3 is a self-pair). The default is 0.

Output argument:
pairs: a 2-by-pair_num matrix with each row containing a unique pair

Cite As

Yifan Gu (2024). rand_unique_pairs(N, pair_num, ordered, self_pair) (https://www.mathworks.com/matlabcentral/fileexchange/61456-rand_unique_pairs-n-pair_num-ordered-self_pair), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2006a
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.2.0.0

Fix some errors

1.1.0.0

Update the description.

1.0.0.0