Monday, May 11, 2009

Matlab: Block randomization

Randomized block design is a common experiment design paradigm. Suppose there are 3 conditions, it seeks to create a random sequence like this:

[3 1 2 2 1 3 1 3 2 1 3 2 1 2 3 2 3 1]

Basically random perm is performed within every size-3 block.

Here's a tip to do this in matlab in one line:

[dump,idx] = sort(rand(nCondition,nTrial));

No comments: