From: Ruben on
Hi,

I would like to create a random number sequence that consists of 12 numbers. Which method can I use best: randperm(12) or randsample(12,12)?

Ruben
From: Walter Roberson on
Ruben wrote:

> I would like to create a random number sequence that consists of 12 numbers.

With or without replacement? Are the numbers to be integers? Chosen from
1:12 ?
From: Ruben on
Thanks for reply. The 12 numbers have to be different integers chosen from 1:12 (so each number from 1 to 12 is used once).What is the best method in matlab to generate these 12 numbers in a random way? Thanks for help!

Ruben
From: Walter Roberson on
Ruben wrote:
> The 12 numbers have to be different integers chosen from 1:12 (so each number from 1 to 12 is used once).What is the best method in matlab to generate these 12 numbers in a random way? Thanks for help!

randperm(12)

is of order N*log(N) and a guarantee of a finite run time.

Any routine that uses selection "with replacement" and compares against the
answers already selected has an infinite tail on the run time.
From: Ruben on
Thanks for reply! I will use randperm(12).

I don't exactly understand what you mean with 'is of order N*log(N)', could you explain it? Would be great. Thanks in advance!

Ruben