| Reference | Downloads | Github

Randomising conditions with different probabilities

Hey everyone,

I have an experiment that is created mostly with the Builder with some code components. I get my conditions from the conditions file I created. I have 12 conditions with two columns in my conditions file. One column determines the number of stimulus and the other goes into the text component. Random option in the Builder means that my conditions will appear with the same probability randomly. However I want my conditions to appear with different probabilities (for some to appear more than the others). I looked up some of the topics here but could not find a full solution. Can I do this with the code component? I’d appreciate any help.

Thanks in advance.


Hello Gamze,

you could set up the stimulus file such that it matches your desired probabilities.

Stim Cond
a 1
a 1
a 1
b 2
b 2
c 1

Cheers Jens

Hey Jens,

Thanks for your reply. This was also the first thing it came to my mind but when I do that I have a file with 180 conditions which makes my experiment way longer. Hence, wanted to inquire about whether coding different probabilities is possible.

Well, an experiment with 180 conditions? You mean trials or real experimental conditions? It is simply copy and paste. :wink:

And yes, it is possible to do this with code. :wink: But my Python is still not good enough to give you some example code.

Cheers Jens

Oh, no no. I mean 180 trials. I’ve used the word conditions because I was talking about my conditions file. I would get 180 rows in my conditions file if I did that. Sorry for the confusion.

Thanks for your time :slight_smile:


If it is trials, simply create the smallest list that reflects your probabilites and set nRep$ so that the product of conditions (trials) and repetition matches your desired number of trials. So, for my toy list mentioned above a nRep$ 30 would give you 180 trials.

In your case with 12 condition, set nRep$ to15.

Cheers Jens

If I create the smallest list that reflects my probabilities I get a list with 180 rows. This is what I meant. I get 180 trials without any nRep$. That is sort of the problem.


Ok, now I get it. Well in this case either code or copy&paste and set nRep$ to 1.

Cheers Jens

You could have a conditions file with 180 trials where you use a code component to break the loop early.

However, what you should probably do is decide which of you variables need to be presented equally and which can be random. The first set form the conditions file and the second set should be randomised in a code component.

Thank you very much for your reply. If I break the loop early, won’t I be also ruining the probabilities though? In the end, I would not get the number of trials I want for one condition I set in the conditions file.

And my variables depend on each other. If I separate them as equally and randomly presented, I might ruin the experiment.

Maybe it is best to explain the experiment now to brainstorm ideas other than coding different probabilities:
I have one stimulus, and this stimulus will be presented some number of times that will change every trial. Participants will be asked to reproduce the duration (that also varies) of the stimulus some number ago (n back). For instance, they will see the stimulus 4 times, and will be asked to reproduce the time of the one 2 stimuli ago. These numbers will change and these are the conditions:

Number of stimulus N back
5 1
5 2
5 3
4 1
4 2
4 3
3 1
3 2
3 3
2 1
2 2
1 1

The problem is that this way the probability that they will be asked to reproduce 1 stimulus ago is higher than the others. However, I want the probability of the n back (1, 2, 3) to be the same. Also since I cannot ask 3 stimuli back if I only show 2 stimuli, these should come like a set I defined above and I should know what I showed and what I asked.

Thank you very very much.