Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
generating a pseudorandom order of trials

Subject: generating a pseudorandom order of trials

From: Renee

Date: 19 Apr, 2010 15:10:27

Message: 1 of 5

Hi,

I'm trying to write a program with 64 trials. Within those 64 trials, 8 different items must be presented 8 different times; however, I need them to appear in random order but not more than 8 times.

What I was trying to do was generate the order of trials based on rand() but that doesn't guarantee exactly 8 trials of each stimulus. Is there a way I can specify a limit on how often something is presented?

Thanks.

Subject: generating a pseudorandom order of trials

From: Rune Allnor

Date: 19 Apr, 2010 15:29:22

Message: 2 of 5

On 19 apr, 17:10, "Renee " <rshim...@csu.fullerton.edu> wrote:
> Hi,
>
> I'm trying to write a program with 64 trials.  Within those 64 trials, 8 different items must be presented 8 different times; however, I need them to appear in random order but not more than 8 times.  

So you want 64 trials containing 8 classes of elements,
each of which can not appear more than 8 times. Can any
one trial contain duplicat classes, or do you require
all trials to contain 8 unique item classes?

If the latter, this is not random but an 8-by-8 sudoku
board.

Rune

Subject: generating a pseudorandom order of trials

From: Steven Lord

Date: 19 Apr, 2010 16:49:18

Message: 3 of 5


"Rune Allnor" <allnor@tele.ntnu.no> wrote in message
news:040b3406-6882-4d7b-89e7-2e41a60dc768@y14g2000yqm.googlegroups.com...
> On 19 apr, 17:10, "Renee " <rshim...@csu.fullerton.edu> wrote:
> > Hi,
> >
> > I'm trying to write a program with 64 trials. Within those 64 trials, 8
> > different items must be presented 8 different times; however, I need
> > them to appear in random order but not more than 8 times.
>
> So you want 64 trials containing 8 classes of elements,
> each of which can not appear more than 8 times. Can any
> one trial contain duplicat classes, or do you require
> all trials to contain 8 unique item classes?
>
> If the latter, this is not random but an 8-by-8 sudoku
> board.

Actually, Sudoku usually adds the restriction that a submatrix also must
contain only one instance of each number. But for a smaller case, 16 trials
with 4 different items, I believe this would be a solution to the OP's
scenario but would not be a Sudoku solution:

[1 2 3 4; 4 1 2 3; 3 4 1 2; 2 3 4 1]

What the OP described sounds more like a Latin square:

http://en.wikipedia.org/wiki/Latin_square

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: generating a pseudorandom order of trials

From: Walter Roberson

Date: 19 Apr, 2010 16:53:26

Message: 4 of 5

Steven Lord wrote:
> "Rune Allnor" <allnor@tele.ntnu.no> wrote in message
> news:040b3406-6882-4d7b-89e7-2e41a60dc768@y14g2000yqm.googlegroups.com...
>> On 19 apr, 17:10, "Renee " <rshim...@csu.fullerton.edu> wrote:

>>> I'm trying to write a program with 64 trials. Within those 64 trials, 8
>>> different items must be presented 8 different times; however, I need
>>> them to appear in random order but not more than 8 times.

> What the OP described sounds more like a Latin square:

A Latin Square has the final line fully constrained by the lines above
it, and thus could not satisfy the original requirements that the order
be _random_ .

items(randperm(8)) done 8 times would satisfy the original criteria.

Subject: generating a pseudorandom order of trials

From: Roger Stafford

Date: 19 Apr, 2010 18:41:22

Message: 5 of 5

"Renee " <rshimizu@csu.fullerton.edu> wrote in message <hqhrp3$r0l$1@fred.mathworks.com>...
> Hi,
>
> I'm trying to write a program with 64 trials. Within those 64 trials, 8 different items must be presented 8 different times; however, I need them to appear in random order but not more than 8 times.
>
> What I was trying to do was generate the order of trials based on rand() but that doesn't guarantee exactly 8 trials of each stimulus. Is there a way I can specify a limit on how often something is presented?
>
> Thanks.
----------------------
  This ought to do the job:

 p = repmat(1:8,1,8); % Each of 1:8 eight times
 p = p(randperm(8*8)); % Rearrange in random order

The vector p contains each of the numbers 1 to 8 eight different times but rearranged to be random order.

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us