# !brew install coreutils
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.
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_file, delimiter=",")
csv_reader for row in csv_reader:
list(map(int, row)))
results.append(
= np.array(results)
res_array
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)}")
= np.unique(A, return_counts=True)
vals, counts print(f"Mode: {vals[np.argmax(counts)]} With count: {counts[np.argmax(counts)]}")
= bins, align='right') plt.hist(A, bins
1]) print_stats(res_array[:,:
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:
1:2]) print_stats(res_array[:,
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…
2:3]) print_stats(res_array[:,
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…
3:4]) print_stats(res_array[:,
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
sum(res_array, axis=1), bins = [x + 0.1 for x in range(9,21)]) print_stats(np.
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
After scaling
= lambda x: x + (20 - x) / 2
f
sum(res_array, axis=1)), bins = [x + 0.1 for x in range(9,21)]) print_stats(f(np.
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