PennController for IBEX › Forums › Support › Randomly get item from certain conditions
Tagged: randomization
- This topic has 7 replies, 3 voices, and was last updated 3 years, 6 months ago by
Jeremy.
-
AuthorPosts
-
January 25, 2021 at 10:09 pm #6545
Rick
ParticipantHi :-),
I have a question on randomization of items from certain experimental conditions.
Say I have a “Data.csv”
Condition Sentence A This is sentence 1 A This is sentence 2 B This is sentence 3 B This is sentence 4 filler I'm filler 1 filler I'm filler 2
I would like to have:
fixed order of items in experiment trials like: A filler B, A filler B, A filler B instead of AA BB fillerfiller (given by Sequence(“Data”))
while A , filler and B in “A filler B” are randomly extracted from each condition.
I was trying to use
Sequence()
function to define the order, however, I found thatSequence()
could only define the order of sessions in the whole experiment and yields:AA BB fillerfiller
Then I tried:
Sequence("Data", seq ("A", "filler", "B")),
but it didn’t work.My original codes are as follows:
PennController.ResetPrefix(null) Sequence("Data", seq ("A", "filler", "B")) Template( "Data.csv" , // Row will iteratively point to every row in myTable.csv row => newTrial( "Data" , newCanvas("empty canvas", 1, 40) .print() , (row.Sentence?[newController("DashedSentence", {s: row.Sentence}) .settings.center() .print() .log() .wait() .remove() ]:null)
If I could not realize from the global “Sequence()” function, what could I do to resolve this problem? Thanks!
January 25, 2021 at 10:54 pm #6550Jeremy
KeymasterHi,
I moved this topic to the Support section of the forums.
I think what you are looking for is the rshuffle function:
Sequence( rshuffle("A","filler","B") ) Template( "Data.csv" , row => newTrial( row.Condition , // etc.
Jeremy
January 25, 2021 at 11:36 pm #6551Rick
ParticipantHi Jeremy,
I’m sorry I didn’t notice the section was not Support section- -|
Yeah, I was wondering how to rshuffle the data internally (condition in Data.csv). Finally, problem resolved with your suggestion.
Thanks so much!
Best,
RickJanuary 27, 2021 at 4:25 pm #6561Rick
ParticipantHi Jeremy,
Sorry to bother you again!
I had tried:
Sequence( rshuffle("A","filler","B") );
but it seems that the trials order is random, instead of A(i) filler(i) B(i), but A B filler (all the way) or Filler B A (all the way) or other kind of orders,
I tried to debug this for a while (to exclude other possibility and keep only A filler B)and found nothing wrong with this expression, could you offer me some suggestions like what I should check to resolve this problem? (If my understanding is not wrong, rshufulle() means keeping the order of A-filler-B, but randomly select elements from materials labelled as A, filler and B to the experiment)
Thanks!
Rick
January 27, 2021 at 5:01 pm #6562Jeremy
KeymasterHi Rick,
The rshuffle function will output a sequence or randomly picked, evenly spaced trials of each label, but the order of the labels is indeed random. So for rshuffle("A","filler","B") you can get six sequence types: [A,filler,B,A,filler,B,etc.], [A,B,filler,A,B,filler,etc.], [filler,B,A,filler,B,A,etc.], [filler,A,B,filler,A,B,etc.], [B,A,filler,B,A,filler,etc.] or [B,filler,A,B,filler,A,etc.].
What do the (i)s refer to in your message?
In any case, it sounds like you could make use of the custom subsequence function defined on this thread. Then you can do this: Sequence( subsequence(randomize("A"),randomize("filler"),randomize("B")) )
Let me know if you have questions
Jeremy
January 27, 2021 at 7:12 pm #6563Rick
ParticipantHi Jeremy,
Thanks so much for your quick reply!
It’s great to know that I misunderstood
rshuffle()
haha I really appreciate for your detailed explanation!This
subsequence()
resolved my problem perfectly!(I tried once and failed, then I realize now that it is a new function that I need to put it on the top of code). I also triedpick()
function you suggested in other place, which also works well. Thanks!Rick
February 17, 2021 at 12:27 pm #6622KJ
ParticipantHello Jeremy,
I was trying the rshuffle function but it didn’t work as I wanted.
I have 6 conditions in total but for each sentence frame one participant should only see one condition of it.
But when I wrote rshuffle(“A”,”B”,”C”,”D”,”E”,”F”), the experiment exhausted all my sentences, so a participant saw 6 variations of a sentence.
What should I do?
Is it because my csv file is in a wrong format?Thanks in advance.
KJ
February 17, 2021 at 1:36 pm #6624Jeremy
KeymasterHello KJ,
The rshuffle function will always exhaust the trials whose labels are referenced. If you want to show different subsets of items to different participants, you could consider using a table for a Group/List design
Jeremy
-
AuthorPosts
- You must be logged in to reply to this topic.