Skip to content

RandomRatio

Sebastian Alves edited this page Sep 22, 2025 · 3 revisions

Random Ratio

The Random Ratio (RR) program configures FED3 to deliver a pellet after a randomly determined number of active pokes. Instead of a fixed requirement (e.g., FR1 or FR5), the ratio requirement changes unpredictably after each reward. In this example, the number of pokes required is randomized between 1 and 10. The inactive port logs pokes but does not deliver reinforcement.

Theory

Random ratio schedules are a type of variable ratio reinforcement in which rewards are delivered after an unpredictable number of responses. Unlike fixed ratio schedules, animals cannot predict exactly how many pokes are required. This produces steady and persistent responding, a hallmark feature of variable-ratio tasks (Ferster & Skinner, 1957). Such schedules are often compared to real-world reinforcement conditions like gambling, where payoff probability is uncertain but strongly motivating.

In operant research, RR tasks are used to study reinforcement strength, motivation, and persistence under uncertainty. They are closely related to variable ratio (VR) schedules in traditional behavioral analysis.

Considerations

  • Randomization range: By default, ratio requirements vary between 1โ€“10 pokes; this range can be adjusted.
  • Logging: Each new random ratio is saved for analysis.
  • Active vs. inactive ports: Only the left port is reinforced. Right pokes are logged but unrewarded.
  • Response patterns: Animals typically show high, steady rates of responding under RR schedules.
  • Analysis: Useful metrics include mean response rate, distribution of inter-pellet intervals, and comparison to fixed-ratio performance.

Key Features

  • Randomly changing ratio requirements (default 1โ€“10 pokes).
  • Each earned pellet resets the requirement to a new random number.
  • Left poke = active, pellet delivery possible.
  • Right poke = inactive, logged but unrewarded.
  • Logs current ratio requirement for each reward event.

Code Highlights

int FR = random(1, 11);                  // Start with random ratio between 1โ€“10

void setup() {
  randomSeed(analogRead(0));             // Seed random number generator
  fed3.begin();                          // Initialize FED3
  fed3.FR = FR;                          // Log/display starting ratio
}

void loop() {
  fed3.run();                            // Keep FED3 hardware updated

  // Left poke (active)
  if (fed3.Left) {
    fed3.Click();                        // Feedback click
    fed3.logLeftPoke();                  // Log left poke
    if (fed3.LeftCount % FR == 0) {      // If requirement met
      fed3.ConditionedStimulus();        // Tone + lights
      fed3.Feed();                       // Deliver pellet
      FR = random(1, 11);                // New random ratio (1โ€“10)
      fed3.FR = FR;                      // Log/display new ratio
    }
  }

  // Right poke (inactive)
  if (fed3.Right) {
    fed3.logRightPoke();                 // Log right poke
    fed3.Click();                        // Feedback click only
  }
}

Usage

  1. Upload this sketch to your FED3 using Arduino IDE.
  2. Observe behavior and log file output.
  3. Modify Ratio Range as needed for your experiment.

Logging

  • Logs pellet events, poke activity, timeouts, and more depending on sketch.

Full Code

/*
  Feeding experimentation device 3 (FED3)
  Random Ratio Script

  Lex Kravitz
  alexxai@wustl.edu
  March, 2022

  This project is released under the terms of the Creative Commons - Attribution - ShareAlike 3.0 license:
  human readable: https://creativecommons.org/licenses/by-sa/3.0/
  legal wording: https://creativecommons.org/licenses/by-sa/3.0/legalcode
  Copyright (c) 2022 Lex Kravitz
*/

////////////////////////////////////////////////////
// Set the FR limits for the random ratio
////////////////////////////////////////////////////
int FR = random(1, 11);                               //Set the min and max for the random ratio.  In this example this is set between 1 and 10.

////////////////////////////////////////////////////
// Start FED3 library and make the fed3 object
////////////////////////////////////////////////////
#include <FED3.h>                                     //Include the FED3 library 
String sketch = "RndRatio";                           //Unique identifier text for each sketch
FED3 fed3 (sketch);                                   //Start the FED3 object

void setup() {
  randomSeed(analogRead(0));
  fed3.begin();                                       //Setup the FED3 hardware
  fed3.FR = FR;                                       //share starting FR ratio with the fed3 library for logging
}

void loop() {
  fed3.run();                                         //Call fed.run at least once per loop

  // If Left poke is triggered
  if (fed3.Left) {
    fed3.Click();                                     //click stimulus
    fed3.logLeftPoke();                               //Log left poke
    if (fed3.LeftCount % FR == 0) {                   //if random ratio is  met
      fed3.ConditionedStimulus();                     //deliver conditioned stimulus (tone and lights)
      fed3.Feed();                                    //deliver pellet
      FR = random(1, 11);                             //randomize the number of pokes required for next pellet
      fed3.FR = FR;                                   //share this new ratio with the fed3 library for logging
    }
  }

  // If Right poke is triggered
  if (fed3.Right) {
    fed3.logRightPoke();                              //Log Right poke
    fed3.Click();                                     //click stimulus
  }
}

References

  • Ferster, C. B., & Skinner, B. F. (1957). Schedules of Reinforcement. Appleton-Century-Crofts.

Navigation

๐Ÿ”ง Get started with FED3

๐ŸŽฎ Program FED3

๐Ÿ Behavioral Code

๐Ÿ“ Example menus (switch between programs without reflashing FED3)

๐Ÿ” FED3 pellets

๐Ÿ“ข FED3 Publications

๐ŸŽจ FED3 Artwork

๐Ÿ˜ตโ€๐Ÿ’ซ FED3 troubleshooting

Clone this wiki locally