Page 1 Results

Page 1 Results Summary

This is a notebook that I used to processed the .csv data from each question. I could just embed it directly into the quarto, but this separation allows me to better outline my thinking while I develop and debug.

Shuffling the results

I will only show the working here once, as I have a workflow in the future.

I am running a notebook on my mac where I use homebrew as a package manager. To shuffle a file inplace, we can use the linux utility shuf, which is a part of coreutils.

# !brew install coreutils

I needed the following command to be ran to properly get the install to go through…

# !brew unlink md5sha1sum
# !brew install coreutils
# !shuf --version
# !cat page1.csv
# !shuf --output=page1.csv <page1.csv
# !cat page1.csv

Since I ran this notebook more than once, the initial CSV is now completely lost…

Per-question results

Question 0 - preparing data

We will be reading the data here, and processing later..

import csv
import numpy as np

results = []

with open('page1.csv') as csv_file:
    csv_reader = csv.reader(csv_file, delimiter=",")
    for row in csv_reader:
        results.append(list(map(int, row)))

res_array = np.array(results)

print(f"Question 1: a) Scores {res_array[:,:1].tolist()}")  
Question 1: a) Scores [[5], [5], [5], [5], [5], [3], [5], [5], [5], [5], [2], [5], [5], [5], [5], [5], [5], [5], [5], [5], [3], [5], [5], [5], [5], [5], [5], [5], [5], [5], [3]]

I decided Numpy would be easy enough to lean on here since it’s a math library…

Question 1

a. A pointer variable is used to:

import matplotlib.pyplot as plt

def print_stats(A, bins = [x + 0.1 for x in range(-1,6)]):
    print(f"Results: {A.tolist()}")
    print(f"Mean: {np.mean(A)}")
    print(f"Median: {np.median(A)}")
    vals, counts = np.unique(A, return_counts=True)
    print(f"Mode: {vals[np.argmax(counts)]} With count: {counts[np.argmax(counts)]}")
    plt.hist(A, bins = bins, align='right')
print_stats(res_array[:,:1])
Results: [[5], [5], [5], [5], [5], [3], [5], [5], [5], [5], [2], [5], [5], [5], [5], [5], [5], [5], [5], [5], [3], [5], [5], [5], [5], [5], [5], [5], [5], [5], [3]]
Mean: 4.709677419354839
Median: 5.0
Mode: 5 With count: 27

b. A reference variable is used to:

print_stats(res_array[:,1:2])
Results: [[5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [3], [5], [5], [5]]
Mean: 4.935483870967742
Median: 5.0
Mode: 5 With count: 30

Question 2

a. Allocate an array…

print_stats(res_array[:,2:3])
Results: [[4], [3], [5], [1], [5], [5], [3], [5], [5], [5], [3], [5], [5], [3], [4], [1], [3], [5], [1], [3], [5], [5], [5], [3], [5], [5], [5], [3], [5], [5], [3]]
Mean: 3.967741935483871
Median: 5.0
Mode: 5 With count: 17

b. Delete the array…

print_stats(res_array[:,3:4])
Results: [[0], [5], [3], [1], [0], [0], [0], [3], [1], [5], [3], [3], [3], [3], [3], [1], [0], [0], [4], [0], [5], [4], [3], [5], [0], [5], [5], [5], [0], [5], [0]]
Mean: 2.4193548387096775
Median: 3.0
Mode: 0 With count: 10

Page results

print_stats(res_array)
Results: [[5, 5, 4, 0], [5, 5, 3, 5], [5, 5, 5, 3], [5, 5, 1, 1], [5, 5, 5, 0], [3, 5, 5, 0], [5, 5, 3, 0], [5, 5, 5, 3], [5, 5, 5, 1], [5, 5, 5, 5], [2, 5, 3, 3], [5, 5, 5, 3], [5, 5, 5, 3], [5, 5, 3, 3], [5, 5, 4, 3], [5, 5, 1, 1], [5, 5, 3, 0], [5, 5, 5, 0], [5, 5, 1, 4], [5, 5, 3, 0], [3, 5, 5, 5], [5, 5, 5, 4], [5, 5, 5, 3], [5, 5, 3, 5], [5, 5, 5, 0], [5, 5, 5, 5], [5, 5, 5, 5], [5, 3, 3, 5], [5, 5, 5, 0], [5, 5, 5, 5], [3, 5, 3, 0]]
Mean: 4.008064516129032
Median: 5.0
Mode: 5 With count: 82
Figure 1: Results for each question on page 1
print_stats(np.sum(res_array, axis=1), bins = [x + 0.1 for x in range(9,21)])
Results: [14, 18, 18, 12, 15, 13, 13, 18, 16, 20, 13, 18, 18, 16, 17, 12, 13, 15, 15, 13, 18, 19, 18, 18, 15, 20, 20, 16, 15, 20, 11]
Mean: 16.032258064516128
Median: 16.0
Mode: 18 With count: 8
Figure 2: Totals for page 1

After scaling

f = lambda x: x + (20 - x) / 2

print_stats(f(np.sum(res_array, axis=1)), bins = [x + 0.1 for x in range(9,21)])
Results: [17.0, 19.0, 19.0, 16.0, 17.5, 16.5, 16.5, 19.0, 18.0, 20.0, 16.5, 19.0, 19.0, 18.0, 18.5, 16.0, 16.5, 17.5, 17.5, 16.5, 19.0, 19.5, 19.0, 19.0, 17.5, 20.0, 20.0, 18.0, 17.5, 20.0, 15.5]
Mean: 18.016129032258064
Median: 18.0
Mode: 19.0 With count: 8
Figure 3: Totals for page 1 after scaling