Howdy, Stranger!

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

Supported by

Counting a Variable

Hello, I have an experiment that I am working on that has participants receiving one of 4 variables randomly and I want the experiment to keep count of how many times the participant receives variables a and b. and at each reiteration of the task if the participant receives variable a or b they are shown a number that increases.

However, I am unable to figure out how to call an instance of the variable occurring and increase the number. Any help would be appreciated

Comments

  • Hi,

    Just to avoid confusion, I suspect that you mean that you have one variable, let's call it my_var, which can have two possible values, 'a' and 'b'. Right?

    If so, you could count the number of occurrences of each value with a simple inline_script like this:

    if var.my_var == 'a':
        var.count_a = var.get('count_a', default=0) + 1
    elif var.my_var == 'b':
        var.count_b = var.get('count_b', default=0) + 1
    

    Cheers!
    Sebastiaan

  • Sebastiaan, This is what I have. I need to count the variables that give the reward of Star and show how many Stars the participant has earned after each instance.

  • Why don't you try to implement my solution yourself first? :) Essentially, all you need to do is change the variable names in the script, and figure out how to insert the script into your experiment.

Sign In or Register to comment.