psychopy.org | Reference | Downloads | Github

Probabilistic feedback on correct answer

Some background info
This is an artificial learning experiment. Four pictures are shown on the screen, participants listen to a sentence from an artificial language and they have to click on the picture that they think matches the auditory sentence. If they pick the correct picture, they will receive feedback. That is, only the target picture will be shown and the sentence will be repeated. This is part of the code I use for that:

while not endTrial:
      if mouse.getPressed()[0]:
        for n, img in enumerate(target_imgs):
          if mouse.isPressedIn(img):
            endTrial = True
            response = 'target'
          feedback(img, target_imgs, target)
        for n, img in enumerate(f1_imgs):
          if mouse.isPressedIn(img):
            endTrial = True
            response = 'foil1'
        for n, img in enumerate(f2_imgs):
          if mouse.isPressedIn(img):
            endTrial = True
            response = 'foil2'
        for n, img in enumerate(f3_imgs):
          if mouse.isPressedIn(img):
            endTrial = True
            response = 'foil3'

The problem
I want them only to get feedback on 75% of their correct responses. So what we’re thinking of is that as soon as the participant selects the correct picture a number will be selected between 0 and 1 and if the number is lower than 0.75 the participant gets feedback and if the number is higher than 0.75 the participant doesn’t get any feedback.

The question
How could I implement that in the current code? Also, if there are other ways to get only feedback on 75% of their correct responses, suggestions are welcome!

Thank you!

Hi @FelicityFF, a simple way to implement feedback on only 75% of correct trials would be to put your feedback in a separate routine, and present that routine conditionally.

if response == "target" and random() > .75:
    continueRoutine = False

If you put this code in the “Begin Routine” tab of the code component in the feedback routine (or in the Each Frame tab if that is not working - see here for explanation), then the feedback routine will not present if the response was “target” and the random value is > .75. So, in that case your feedback will present for all incorrect trials, but with only 75% probability on correct trials.

1 Like

Hi @dvbridges, Thank you for your reply! I’m not exactly sure whether I understand where to put the code. I’m not using builder. Does this code have to be implemented in the code I provided above, or do I have to get rid of that piece of code and only use this? If so, where do I have to put it?

Apologies @FelicityFF, I assumed the use of Builder, although I would highly recommend using Builder to create your experiment. There are various advantages, such as ensuring good timing of your components, and if you need the flexibility of code, you can add code components.

If coding yourself, the concept for my code snippet is the same, but you need to add code that presents the exit screen conditionally.