Howdy, Stranger!

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

Supported by

Is it possible to modify the probability of a variable to be run in an experiment ?

Hi, im creating a subitizing experiment,

I have 8 variables named 'target1_color' , 'taget2_color' ....

I have specified in a loop the different color the target should have (white or gray)

However I want the variable white to appear less often then the variable gray.

The variable 'gray' should have p=0,625 to appear
the variable 'white' p=0,375 to appear

is there an inline_script code that i should use in this case ?

Comments

  • I have an idea about how to do it but as i don't know how to code i can't make it happen

    my idea is to generate random numbers from 1 to 1000
    give at my target variable a random number

    for exemple 'target1_color' = 2

    attribute to numbers a color : (1,375) = white
    (376, 1000) = gray

    i don't know if this can work

    from random import
    print randtint (1, 1000)

    (1,375) = white
    (376, 1000) = gray

    search_canvas = items['target_position'].canvas
    search_canvas['target1']
    .

  • from ramdom import

    search_canvas = items[var.target_dispaly]

    [var.color_x] = randtin (1,1001)

    if [var.color_x] < 376 :
    [var.color_x]= white

    else:
    var.color_x= grey

  • edited April 2018

    Hi Paul,

    yes your idea makes perfect sense. Here some code that does the trick:

    import random
    
    num = random.randint(1,1000)
    if num<276:
        var.target_color = 'white'
    else:
        var.target_color = 'gray'
    # and later
    
    cv = Canvas()
    cv.circle(0,0,50,color=var.target_color,fill=True)
    cv.show()
    # and wait
    

    Does that make sense?

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.