Week 5 laboratory · 7 October

Does one change to the task change your speed?

Tonight you edit your Week 2 reaction-time page so it runs two versions of the task, A and B. You predict which one will be slower, run both, and compare them. Two averages are not enough: you also look at how spread out the trials are and how much the two sets overlap.

Compare tool

Load your CSV

Write your prediction first, then load data.

Step 1 · everyone · about 60 minutes

Make your page run two conditions

  1. In VS Code, make a folder week05-compare/ in your private repo. Copy your week02-rt/rt.html into it. Copy the Week 5 README into it too.
  2. Before you change any code, fill in the Prediction section of the README: which condition will be slower, by roughly how many ms, and why. Commit it. The commit time is your proof it came first.
  3. Pick one thing to change between A and B that you think will change speed: square size (72 vs 20 pixels), waiting time (always 1000 ms vs random 800–2200 ms), or brightness (bright vs dim). Not a colour you just like.
  4. Edit the code. You need all five changes:
    // (a) near the top: which condition is running
    let condition = "A";
    
    // (b) in keyPressed(): A and B keys switch condition
    if (key === "a" || key === "b") {
      condition = key.toUpperCase();
      note = "Condition " + condition + ". Click Start.";
    }
    
    // (c) in draw() or beginTrial(): make B different. Example for size:
    const size = condition === "A" ? markSize : 20;
    rect(width / 2, height / 2 + 10, size, size, 10);
    
    // (d) add condition to BOTH results.push({...}) calls,
    //     to the CSV header, and to the .join(",") list
    condition: condition,
    
    // (e) in startBlock(): delete  results = [];
    //     so block B does not erase block A
  5. Run it: Practice 6, press a, Start 20, press b, Start 20, Export. You should get one CSV with a condition column and at least 40 scored rows. Rename it rt-week05.csv and put it in week05-compare/.
  6. Load it above. Value column rt, condition column condition. Copy the table into your README and write one sentence: did the data agree with your prediction?

The tool leaves out practice trials, anticipations, rows marked usable = 0, wrong answers (correct = 0), and times outside 150–2500 ms.

Step 2 · harder

Make condition B a choice

In A, one square, one key (simple reaction time). In B, the square appears on the left or the right at random. Press f for left and j for right. This is the comparison Donders made in 1868; you will read about it next week.

  1. In beginTrial(), pick a side: side = random() < 0.5 ? "left" : "right"; (declare let side; at the top).
  2. In draw(), in B draw the square at width * 0.25 or width * 0.75 instead of the middle.
  3. In keyPressed(), in B send f and j to handleResponse(key); in A keep the space bar.
  4. In handleResponse(k), work out correct (always 1 in A). Add side and correct to the results and the CSV.
  5. Run new blocks. Report how many errors you made in B. Errors are left out of the mean.
Step 3 · hardest

Do the comparison in Python

Copy week04-report/scripts/summarize.py to week05-compare/compare.py and change it so that it:

  1. keeps only scored trials (same rules as this page);
  2. splits the rows by the condition column and prints n, mean, and SD for A and for B, then B − A;
  3. prints the overlap number: out of every possible pair of one A trial and one B trial, the percentage where B is slower;
  4. saves compare.png with both conditions on one figure.

Check: your Python numbers must match this page. If they do not, find out why and say so in the README.

Tonight

Agenda

18:00 Why compare?
A difference means something only with a prediction and a spread. Write your prediction.
18:20 Demo
The sample file on this page, and what the overlap number means.
18:35 Step 1
Edit the code, run both blocks, load the CSV.
19:35 Steps 2 and 3
Go as far as you can. Finish at home before Tuesday.
20:15 Project ideas
Bring one question you could answer with something from Weeks 2–5. We talk them through in small groups. Nothing to hand in.
Weekly report · due Tuesday 13 October, 17:00

What to submit

Push week05-compare/ with your edited rt.html, your CSV, and the filled README.md (plus compare.py and compare.png if you did Step 3). On Canvas, paste the folder path, your prediction, the two ns and means, the difference, and your AI disclosure. Step 1 done well is worth 8 of 10; Steps 2 and 3 are worth one point each. Rubric.