{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Week 4 Lab: Associative Learning Models\n",
    "\n",
    "This week formalizes how organisms learn predictive relationships between events.\n",
    "The lab implements two associative-learning models as **recursive update rules**,\n",
    "where the state at trial $t$ feeds into trial $t+1$:\n",
    "\n",
    "- **Part 1 - Rescorla-Wagner.** Learning is driven by prediction error:\n",
    "  $$\\Delta V_i = \\alpha_i\\,\\beta\\,(\\lambda - V_{total}), \\qquad V_{total} = \\sum_i V_i$$\n",
    "  Use it to reproduce acquisition, blocking, overshadowing, overexpectation, and\n",
    "  conditioned inhibition.\n",
    "- **Part 2 - Mackintosh (1975).** Extends prediction-error learning with a dynamic\n",
    "  *associability* (attention) term that itself updates across trials.\n",
    "\n",
    "Code cells are left blank for you to fill in. Both models are pure simulations -\n",
    "no data files are needed for Part 1."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Setup\n",
    "\n",
    "Import `numpy`, `pandas`, `matplotlib`, and `seaborn`."
   ]
  },
  {
   "cell_type": "code",
   "metadata": {},
   "execution_count": null,
   "outputs": [],
   "source": [
    "# Import your libraries here\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Part 1: The Rescorla-Wagner Model\n",
    "\n",
    "### Task 1: Implement the update rule and simulate acquisition\n",
    "\n",
    "Write a function that takes a list of trials - each trial is the set of stimuli present plus the US asymptote `lambda` (1.0 when the US occurs, 0.0 when it does not) - and applies the Rescorla-Wagner rule $\\Delta V_i = \\alpha_i\\,\\beta\\,(\\lambda - V_{total})$, where $V_{total}$ sums associative strengths over the stimuli present on that trial. Use it to simulate simple acquisition of a single CS and plot $V$ across trials."
   ]
  },
  {
   "cell_type": "code",
   "metadata": {},
   "execution_count": null,
   "outputs": [],
   "source": "# Define rescorla_wagner(trials, alpha_A, alpha_B, beta) and simulate acquisition of a single CS\n"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Task 2: Reproduce blocking, overshadowing, overexpectation, and conditioned inhibition\n",
    "\n",
    "Each phenomenon falls out of the shared prediction-error term $(\\lambda - V_{total})$. Build the trial schedules and confirm the signatures:\n",
    "\n",
    "- **Blocking:** train A->US alone, then AB->US. B barely learns ($V_B \\approx 0$).\n",
    "- **Overshadowing:** train AB->US with $\\alpha_A > \\alpha_B$. A captures more of $\\lambda$.\n",
    "- **Overexpectation:** train A->US and B->US separately to asymptote, then AB->US together. Both $V$ values *decrease* because $V_{total} \\approx 2\\lambda$ overpredicts.\n",
    "- **Conditioned inhibition:** interleave A->US with AB->no US. B acquires *negative* strength."
   ]
  },
  {
   "cell_type": "code",
   "metadata": {},
   "execution_count": null,
   "outputs": [],
   "source": [
    "# Build trial schedules for blocking, overshadowing, overexpectation, conditioned inhibition\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Part 2: The Mackintosh Model (Recursive Associability)\n",
    "\n",
    "### Task 3: Implement the model\n",
    "\n",
    "The Mackintosh (1975) model adds a dynamic *associability* term: a stimulus that predicts the US better than its competitors gains attention (its $\\alpha$ rises), while a poorer predictor loses it. Implement the update rules for association strength $V$ and associability $\\alpha$, then write simulation functions for (a) basic conditioning, (b) overshadowing (two CSs with different initial associability), and (c) blocking (CS1 trained alone, then CS1+CS2)."
   ]
  },
  {
   "cell_type": "code",
   "metadata": {},
   "execution_count": null,
   "outputs": [],
   "source": "# Define the Mackintosh update rules (each CS uses its own prediction error)\n# and simulate_basic_conditioning / simulate_overshadowing / simulate_blocking\n"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Task 4: Run the simulations and visualize\n",
    "\n",
    "Run each simulation across a range of learning rates (theta), combine the results, and plot association strength and associability over trials. Confirm the expected signatures: overshadowing (CS1 gains more $V$ than CS2) and blocking (CS2 shows minimal learning in Phase 2)."
   ]
  },
  {
   "cell_type": "code",
   "metadata": {},
   "execution_count": null,
   "outputs": [],
   "source": [
    "# Run basic/overshadowing/blocking simulations across theta values and plot V and alpha\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Wrap-up\n",
    "\n",
    "Compare the two models. The Rescorla-Wagner model explains blocking, overshadowing, overexpectation, and conditioned inhibition entirely through a shared prediction-error term with *fixed* saliences. What does the Mackintosh model add by letting associability change across trials, and which phenomena motivate that addition? Where in each update rule does the recursive structure $X(t+1) = f(X(t), I(t))$ appear?"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
