THINK FIRST·CODE LATER

← All labs

Report a comparison with a confidence interval

Problem

Input: a CSV participant,table,chart with each participant's time (s) for the same kind of question with a table and with a chart (within-subjects).

Compute the differences table − chart and print:

n=8: mean time table 49.4 s, chart 38.8 s
mean difference (table - chart) 10.6 s, 95% CI [6.4, 14.9]
paired t(7) = 5.93, p = 0.0006, effect size dz = 2.10
8 of 8 participants were faster with the chart
conclusion: the chart is faster on average; the CI excludes 0

The CI is mean ± t₀.₉₇₅,ₙ₋₁ × sd/√n (scipy.stats.t.ppf), the test scipy.stats.ttest_rel, dz = mean difference / sd of differences. Conclusions: CI entirely above 0 → chart faster; entirely below 0 → conclusion: the table is faster on average; the CI excludes 0; otherwise conclusion: no reliable difference; the CI includes 0 (more participants needed?).

Data for this lab

Your program reads its data from standard input. Download the file, then give it to your program as shown below. Start with data set 1: its expected output is given.

v14-2-data-1.csv

participant,table,chart
P1,42,30
P2,55,41
P3,38,35
P4,61,44
P5,47,39
P6,50,36
P7,44,40
P8,58,45
What your program must print for v14-2-data-1.csv
n=8: mean time table 49.4 s, chart 38.8 s
mean difference (table - chart) 10.6 s, 95% CI [6.4, 14.9]
paired t(7) = 5.93, p = 0.0006, effect size dz = 2.10
8 of 8 participants were faster with the chart
conclusion: the chart is faster on average; the CI excludes 0

Run your program first, then open this and compare line by line: your output must contain these lines exactly.

How to give the file to my program

Terminal (macOS, Linux, or Windows Command Prompt), in the folder that holds both files:

python my_lab.py < v14-2-data-1.csv

Windows PowerShell (the default terminal of VS Code on Windows) does not understand <:

Get-Content v14-2-data-1.csv | python my_lab.py

PyCharm: Run → Edit Configurations → tick Redirect input from and choose the file.

Jupyter: put this at the top of the cell that holds your program:

import sys
sys.stdin = open("v14-2-data-1.csv", encoding="utf-8")

Write it here, in Jupyter or in your IDE, then paste it. Run it on the sample input yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.