How to ensure equal probability of stim appearing on L or R of screen without hard-coding? Description inside.

1 回表示 (過去 30 日間)
Hi,
I am working on a task in Psychtoolbox where I'd like to display a stimulus 50% of the time on the left side of the screen, and 50% on the right side. Is there a way to ensure an equal balance of where the stimulus will appear without hard-coding? I would like it to be random (but always balanced) each time I run the task, but am not sure how to set this up. Thanks!

採用された回答

Walter Roberson
Walter Roberson 2015 年 12 月 29 日
50% turns out to be surprisingly tricky
  4 件のコメント
Chelsea
Chelsea 2016 年 1 月 7 日
Thank you! I will go try to understand this now :) :) Immensely appreciated!!
Chelsea
Chelsea 2016 年 4 月 1 日
Hi Walter,
You helped me with this code several months ago so I'm wondering if you could point me in the right direction with it! :)
I need to change the ratio of same side 3/4 and opposite side 1/4 to 2/3 and 1/3, respectively. It sounds super easy, but I don't think I'm getting the right output?
scramble = @(v) v(randperm(numel(v)));
N = 40;
show_same_side = scramble([false(1,N), true(1,3*N)]);
side_to_show1 = scramble([1*ones(1,2*N), 2*ones(1,2*N)]);
side_to_show2(show_same_side) = side_to_show1(show_same_side);
side_to_show2(~show_same_side) = 3 -side_to_show1(~show_same_side);
I changed the 3s to 2s... Is there anything else/different I'd need to do?
Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTiming and presenting 2D and 3D stimuli についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by