## noreplacenorepeat for unequal number of trials

##### noreplacenorepeat for unequal number of trials
 Author Message writekristin posted 9 Years Ago ANSWER HOT Group: Forum Members Posts: 17, Visits: 62 I am trying to write an experiment that has four trials but I want to run two of the trials twice as many times as two of the others.i.e. run each trial this number of times:trial1:12trial2:24trial3:24trial4:12In order to do this, I know I need to do noreplace(trial1, trial2, trial2, trial3, trial3, trial4), however I also don't want the same trial to run consecutively.  Unfortunately, noreplacenorepeat(trial1, trial2, trial2, trial3, trial3, trial4) does not seem to accomplish this!  Now it runs in the right proportions, but it will happen where I get for example: trial2, trial2, trial2.  Any advice? :( Dave posted 9 Years Ago ANSWER Group: Administrators Posts: 13K, Visits: 102K You need to set up a element for selection to do this:/ trials = [1-72=list.triallist]/ items = (trial.a, trial.b, trial.c, trial.d)/ itemprobabilities = (0.166, 0.333, 0.333, 0.166)/ poolsize = 72/ maxrunsize = 1/ validresponse = (0)/ trialduration = 100/ validresponse = (0)/ trialduration = 100/ validresponse = (0)/ trialduration = 100/ validresponse = (0)/ trialduration = 100 Edited 9 Years Ago by Dave writekristin Group: Forum Members Posts: 17, Visits: 62 thanks!  this does seem to work, although we did end up having some repeats at the end (e.g. trial.c, trial.c, trial.c), i suppose because it ran out of options in the end which can't be helped.can you explain to me what it would mean to select with vs. without replacement in this case?  initially i thought selecting without replacement would mean it would select each of trial a, b, c, d, before reselecting them again, but this doesn't seem to be the case (and wouldn't really make sense for us anyway, since we have more b&c than a&d). Dave posted 9 Years Ago ANSWER Group: Administrators Posts: 13K, Visits: 102K > this does seem to work, although we did end up having some repeats at the end (e.g. trial.c, trial.c, trial.c), i suppose because it > ran out of options in the end which can't be helped.That's exactly right. You'll also find this detailed in the documentation: "Random selection is done on the fly, so if multiple selection constraints such as not or replace are in place, it may not be possible to satisfy them all on a give trial, especially if there are only a few remaining items in the selection pool. In that case, the list will suspend one of the constraints and try again. If it still can not satisfy the remaining constraints, it suspends another and tries again, and so forth. By default, the maxrunsize constraint is suspended first, then replace, and finally the not constraints. If a procedure requires that the constraints always be satisfied, pregenerate a set of selection sequences that satisfy the constraints and then randomly select one of the pregenerated sequences to use for a given session."> can you explain to me what it would mean to select with vs. without replacement in this case?The creates a pool of 72 items to sample from (/poolsize). The pool is populated with items according to the given proportions / probabilities (/itemprobabilities).The pool is sampled from according to the specified mode in /selectionmode and /replace. Sampling without replacement ensures that you end up with exactly 12 elements of type A, 24 of type B, 24 of type C, and 12 of type D. Sampling with replacement does not give you that guarantee. Think of it as drawing from a deck of cards with 12 red cards, 24 green cards, 24 blue cards, and 12 yellow cards, and drawing cards from the deck either with or without putting the drawn card back into the deck. Edited 9 Years Ago by Dave writekristin Group: Forum Members Posts: 17, Visits: 62 ok, got it, thank you!  i tend to get confused about whether with/without replacement refers to (if i have a of trials) the type of (i.e. must use each type of trial a, b, c, d, before being able to use them again if taking without replacement) vs. selecting the underlying stimuli without replacement.  with the , it seems like refers to the former.so i have another question now!  it turns out i need to give different feedback based on a second binomial variable within the trial types.  so now i have: = 6 = 6 = 12 = 12 = 12 = 12 = 6 = 6once again, i do not want the same type of trial a, b, c, d, run consecutively. i can make a similar list like before, but then there is the possibility i will get trial.a_1, trial.a_2 consecutively, when i really don't want any trial of type a consecutively:/ items = (trial.a_1, trial.a_2, trial.b_1, trial.b_2, trial.c_1, trial.c_2, trial.d_1, trial.d_2)/ itemprobabilities = (0.083, 0.083, 0.166, 0.166, 0.166, 0.166, 0.083, 0.083)/ poolsize = 72/ maxrunsize = 1 i tried making lists that group trial.a_1, trial.a_2 together first, then doing a triallist of lists, but this did not seem to work.i hope this makes sense!  thanks. Dave posted 9 Years Ago ANSWER Group: Administrators Posts: 13K, Visits: 102K You can in fact make a list of lists and use that for trial selection as before. Simple example below:/ trials = [1-8 = list.masterlist]/ items = (list.a.nextvalue, list.b.nextvalue)/ poolsize = 8/ maxrunsize = 1/ items = (trial.a1, trial.a2)/poolsize = 4/ items = (trial.b1, trial.b2)/ poolsize = 4/ stimulusframes = [1=mytext]/ validresponse = (57)/ stimulusframes = [1=mytext]/ validresponse = (57)/ stimulusframes = [1=mytext]/ validresponse = (57)/ stimulusframes = [1=mytext]/ validresponse = (57)/ items = ("<%script.currenttrial%>")You may also want to consider whether you really need two separate elements (a1, a2) per "type" (here: a). In most cases, it should be possible to realize the different feedback conditions with only one element per type (e.g. change the feedback at runtime as needed via conditional logic). Edited 9 Years Ago by Dave writekristin Group: Forum Members Posts: 17, Visits: 62 thank you!  i was missing the "nextvalue."yes, i was considering that also regarding using conditional logic.  trial's a_1 and a_2 use different stimuli though, so i am wondering how to distinguish in the trial which stimuli it was using.if i have picture.a_1 and picture.a_2, and have trial.a select noreplacenorepeat(picture.a_1, picture.a_2), is there a way to access which one it used?alternatively, i was thinking of combining them in picture.a, and using the currentitem property, which would work in this case because we have named the pictures accordingly to 1 vs 2. Dave posted 9 Years Ago ANSWER Group: Administrators Posts: 13K, Visits: 102K I would do the latter which boils down to something like this (works the same with elements):/ itemnumber = 1/ trials = [1-4=mytrial]/ ontrialbegin = [values.itemnumber = list.itemnumbers.nextvalue]/ stimulusframes = [1=mytext]/ validresponse = (57)/ items = ("A", "B")/ select = values.itemnumber/ items = (1,1,2,2)/ maxrunsize = 1 writekristin Group: Forum Members Posts: 17, Visits: 62 Regarding the list of lists, I actually can't seem to get that to work./ items = (trial.a_1, trial.a_2)/ itemprobabilities = (0.5, 0.5)/ poolsize = 12/ selectionmode = random/ replace = false/ items = (trial.b_1, trial.b_2)/ itemprobabilities = (0.5, 0.5)/ poolsize = 24/ selectionmode = random/ replace = false/ items = (trial.c_1, trial.c_2)/ itemprobabilities = (0.5, 0.5)/ poolsize = 24/ selectionmode = random/ replace = false/ items = (trial.d_1, trial.d_2)/ itemprobabilities = (0.5, 0.5)/ poolsize = 12/ selectionmode = random/ replace = false/ items = (list.a.nextvalue, list.b.nextvalue, list.c.nextvalue, list.d.nextvalue)/ poolsize = 72 / itemprobabilities = (0.166, 0.333, 0.333, 0.166)/ maxrunsize =  1/ trials = [1-72=list.trial_selector]For one, the probabilities seem to be off.  I have one situation where I have 11 trial.c_1 and 13 trial.c_2, when I expected 12 of each.  Also I am still getting consecutive trial.c_1, trial.c_2, when I was hoping to not get any consecutive trials of "type" c, which was why I was attempting a list of lists in the first place.  Thoughts? Dave posted 9 Years Ago ANSWER Group: Administrators Posts: 13K, Visits: 102K The better approach in this particular scenario is to work with dummy elements (or re-think whether you really need two separate s per type as already discussed):/ items = (trial.a_1, trial.a_2)/ itemprobabilities = (0.5, 0.5)/ poolsize = 12/ selectionmode = random/ replace = false/ items = (trial.b_1, trial.b_2)/ itemprobabilities = (0.5, 0.5)/ poolsize = 24/ selectionmode = random/ replace = false/ items = (trial.c_1, trial.c_2)/ itemprobabilities = (0.5, 0.5)/ poolsize = 24/ selectionmode = random/ replace = false/ items = (trial.d_1, trial.d_2)/ itemprobabilities = (0.5, 0.5)/ poolsize = 12/ selectionmode = random/ replace = false/ items = (trial.a, trial.b, trial.c, trial.d)/ poolsize = 72/ itemprobabilities = (0.166, 0.333, 0.333, 0.166)/ maxrunsize =  1/ trials = [1-72=list.trial_selector]/ branch = [list.a.nextvalue]/ recorddata = false/ trialduration = 0/ branch = [list.b.nextvalue]/ recorddata = false/ trialduration = 0/ branch = [list.c.nextvalue]/ recorddata = false/ trialduration = 0/ branch = [list.d.nextvalue]/ recorddata = false/ trialduration = 0/ trialduration = 10/ trialduration = 10/ trialduration = 10/ trialduration = 10/ trialduration = 10/ trialduration = 10/ trialduration = 10/ trialduration = 10

#### Merge Selected

Merge into selected topic...

Merge into merge target...

Merge into a specific topic ID...