How to write randomisation with constraints (i.e., pseudorandomisation)? #2755
Unanswered
IngridYu0211
asked this question in
Q&A
Replies: 1 comment 1 reply
-
To shuffle again each time a constraint is not met, I would implement a while loop that first shuffles the array. Then check the constraints and if one of them is not met the while loop repeats.
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'd like to ask about pseudorandomisation. My task has 3 independent variables- the levels of partner knowledge (good/poor), levels of own knowledge (good/poor) and context (competitive/non-competitive). I hence have 222=8 blocks. I varied partner identities so that participant only encountered players B and C in competitive context; and D and E in non-competitive context.
I want to pseudorandomise the block order so that
My code currently looks like this without the pseudorandomisation:
var blockPlayerFactorsA = {
blockFrame:['competitive'],
otherIdentity:['playerB', 'playerC'],
selfSpeed: ['slow','fast']
}
var blockPlayerComboA = jsPsych.randomization.factorial(blockPlayerFactorsA, 1);
for (block_number=2; block_number<=TotalBlockNumber; block_number++) {
var thisBlockCombo=FPcomboArray[block_number-2];
.... }
Can someone please help me implementing the constraints? How can I do something like 'shuffle again if player identity was the same for two adjacent blocks'? And no more than 2 consecutive competitive/non-competitive blocks?
Thanks very much in advance!
Beta Was this translation helpful? Give feedback.
All reactions