Simultaneously sampling from two variables #2725
-
Hello, I am struggling to sample from two variables simultaneously. Specifically, in each trial, I would like to present a I have looked into several resources—such as sampling without replacement, custom sampling and position indices—but to no avail. I'm a beginner at this, so it's possible that one of these resources was relevant (especially the last one, I think). Could you please consider my code below? In addition to the parallel sampling, how could I save the same trial index in the Thank you so very much for your attention * I've also posted on SO. If a solution is found, I will link to it on other question.
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
I have somehow advanced on this by using position indices. I provide the updated code below. However, this code still presents two problems:
Thank you very much for your attention
|
Beta Was this translation helpful? Give feedback.
-
Hi @pablobernabeu! Your general approach in the second post looks great to me. For (1), I think you're getting the bug because you're indexing the prime and target arrays using the values 1-4 instead of 0-3. For (2), yes I think you could improve this by creating a loop to construct your let stimuli = [];
for (let i=0; i<number_of_trials; i++) {
let trial = {
primeWord: primeWords[i],
targetWord: targetWords[i],
correct_response: 'abstract',
trial: i,
interstimulus_interval: interstimulus_interval[i]
};
stimuli.push(trial);
} I think you could do the same thing with I hope that helps! |
Beta Was this translation helpful? Give feedback.
-
Finally solved using position indices in a for-of loop (see below: 'For loop that creates trial information iteratively over trials (3 steps)').
|
Beta Was this translation helpful? Give feedback.
Finally solved using position indices in a for-of loop (see below: 'For loop that creates trial information iteratively over trials (3 steps)').