Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Randomize within a sequential order of Loop

Hi everyone!

Thank you in advance to whom might take his/her time reading this and possibly answering.

I'm programming an Iowa Gambling Task in opensesame 3.3, back-end Xpyriment, python 3.7.10.

Basically the task consists of 4 decks of cards that the participant has to chose to draw a card from. Each deck has an order for gains and losses outcomes. Basically, each 10 trials, A and B will lead to a loss of 250 points each, and C and D to a gain of 250 points each. Within 10 trials, the order is supposed to be randomized. So, it is a randomization within each block of 10 trials.

I have programmed this by doing in the excel the randomization, and inserted the table in a sequential loop with all the 100 trials I'm doing (see figure).

The experiment is working successfully, but I have a problem now: I wanted to randomize for each participant, and doing a version per participant is not doable. Can anybody help me with some code for this?

Thanks a lot!!

All the best, this forum has helped a great deal (it's my first experiment!!!)

Júlia RM


Comments

  • edited December 6

    Hi @julia_reis_ulisboa

    I’m not completely sure I follow your intended structure, but I'll try to help anyway!

    Setting the loop’s order to "random" (like you did in your screenshot) will shuffle all 100 rows once per run. That means you do get a different order for each participant, but it does not preserve the 10-trial block structure I believe you want to keep.

    If you want each 10-trial block to be randomized independently, a better approach is to:

    • keep only the 10 rows for a single block in your table
    • set "repeat" to 10
    • keep "order = random"

    With this setup, each repetition will reshuffle those 10 trials vertically, giving you a new random order for every 10-trial block and for every participant.

    If you also need to randomize the outcomes across decks within each row, you could use the script view of the loop table and add a line at the end like: 'shuffle_horiz outcome_A outcome_B outcome_C outcome_D' (see here for an example: Visual world // OpenSesame documentation).

    This shuffles the values within rows (not the columns). And if you only want partial horizontal shuffling, you can specify subsets e.g., if your loop script has 20 lines, you can add 'shuffle_horiz outcome_A outcome_B' at line 21, and 'shuffle_horiz outcome_C outcome_D' at line 22.

    Let me know if that helps - and if not, could you be more specific?

    Claire

  • Hi Claire!

    Thank you so much for your reply!

    I thought i had sequential order, but i must have switched by accident when print screening.

    That would absolutely work but isn't this doing a 10-row shuffle each trial? I mean, I would want no repetition, is that what random does? That way I would make sure that every 10 trials the sum is the same (-250 for decks A and B, and +250 for decks C and D). Is that it?

    Thank you again!!!

  • It works!!! Thank you so much, Claire!

Sign In or Register to comment.