0
$\begingroup$

I was wondering if it's possible to automatically pseudo-randomize stimuli in R? If so, I would be very grateful for any help.

$\endgroup$
2
  • $\begingroup$ Pseudo randomness is typically just a random permutation. You can write code to do this in any general language. Not sure what you mean by "automatically". $\endgroup$
    – Bryan Krause
    Commented Jan 25, 2021 at 15:59
  • $\begingroup$ I was actually looking for tips on how to do that, I am sorry for not being clear. $\endgroup$ Commented Jan 26, 2021 at 16:08

1 Answer 1

1
$\begingroup$

You can use the "sample" function: https://stat.ethz.ch/R-manual/R-devel/library/base/html/sample.html

Start with a list of the stimuli you want to present. For example, if you have two stimuli that should be repeated 4 times each, your list would be c(1,1,1,1,2,2,2,2)

If you take 8 samples from this distribution without replacement, you have a random permutation of the list. This is the default behavior if you just give the original list, like this:

sample(c(1,1,1,1,2,2,2,2))
$\endgroup$
3
  • $\begingroup$ Thank you! As I understand this would not necessarily create a pseudo-randomization, but a randomization instead. I was actually wondering how to create pseudo-randomized lists in which for example the same condition cannot come up more than 3 times in a sequence. So if I example conditions a, b, c, d, the script would create patterns such as aabbccddaaabbbcccddd or similar to that. $\endgroup$ Commented Jan 28, 2021 at 11:24
  • 2
    $\begingroup$ @rhododendron What I write is also pseudorandom, because it's sampling without replacement. For what you describe you could do a block randomization where you take consecutive draws from a smaller number of stimuli and then stitch them together. $\endgroup$
    – Bryan Krause
    Commented Jan 28, 2021 at 12:25
  • $\begingroup$ @rhododendron could you give us more details on what the constrains are and how long the sequence should be? Maybe we could then give a more fitting reply :) $\endgroup$
    – bucky
    Commented Jan 31, 2021 at 9:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.