Millisecond Forums

Random selection without replacement

https://forums.millisecond.com/Topic13736.aspx

By Diane - 7/2/2014

Hi,


I have four picture elements that randomly select an item from an item element. However, I noticed that sometimes an item is selected more than once, even though I used the "noreplace" attribute. How can I randomly select without replacement? 

This is the relevant part of the code:

<item recallcues>
</item>

<trial fillrecallcues>
/ontrialbegin = [item.recallcues.item=item.poweritems1.1;
                 item.recallcues.item=item.indexitems2.1;
                 item.recallcues.item=item.fingeritems3.1;
                 item.recallcues.item=item.parallelitems4.1]
/ trialduration = 0
</trial>

<picture recallcue1>
/items = recallcues
/select = noreplace
/size = (20%,20%)
/ position = (10,10)
</picture>

<picture recallcue2>
/items = recallcues
/select = noreplace
/size = (20%,20%)
/ position = (30,10)
</picture>

<picture recallcue3>
/items = recallcues
/select = noreplace
/size = (20%,20%)
/ position = (50,10)
</picture>

<picture recallcue4>
/items = recallcues
/select = noreplace
/size = (20%,20%)
/ position = (70,10)
</picture>

Thanks,

Diane
By Dave - 7/2/2014

See e.g. https://www.millisecond.com/forums/FindPost13609.aspx.

What you need to realize is that having several stimulus elements (<text>, <picture>) reference the same <item> element

<picture recallcue1>
/items = recallcues
/select = noreplace
/size = (20%,20%)
/ position = (10,10)
</picture>

<picture recallcue2>
/items = recallcues
/select = noreplace
/size = (20%,20%)
/ position = (30,10)
</picture>
...

does *not* establish a single selection pool for all those stimulus elements. They are independent and each one will sample from *all* the items given in the <item> element without replacement. I.e.

<text text1>
/ items = myitems
/ select = noreplace
...
</text>

<text text2>
/ items = myitems
/ select = noreplace
...
</text>

<item myitems>
/ 1 = "A"
/ 2 = "B"
/ 3 = "C"
/ 4 = "D"
</item>

is equivalent to stating

<text text1>
/ items = ("A", "B", "C", "D")
/ select = noreplace
...
</text>

<text text2>
/ items = ("A", "B", "C", "D")
/ select = noreplace
...
</text>
By Diane - 7/3/2014

Hi Dave

Thanks. That link doesnt seem to work, but perhaps my question can be solved in a different way.

The reason I have made 4 recallcue picture elements is that I want four pictures at four different locations on the screen, and which picture goes where should be random. Is there a way to do that with one picture element?


Thanks

Diane
By Dave - 7/3/2014


And, yes, of course that's possible:

<trial mytrial>
/ stimulusframes = [1=t1,t2,t3,t4]
/ validresponse = (57)
</trial>

<text t1>
/ items = myitems
/ position = (20%, 50%)
/ select = list.mylist.nextvalue
</text>

<text t2>
/ items = myitems
/ position = (40%, 50%)
/ select = list.mylist.nextvalue
</text>

<text t3>
/ items = myitems
/ position = (60%, 50%)
/ select = list.mylist.nextvalue
</text>

<text t4>
/ items = myitems
/ position = (80%, 50%)
/ select = list.mylist.nextvalue
</text>

<item myitems>
/ 1 = "A"
/ 2 = "B"
/ 3 = "C"
/ 4 = "D"
</item>

<list mylist>
/ items = (1,2,3,4)
/ selectionrate = always
</list>

(works the same for <picture> elements).