Menu
CoddyTech

Difference in Means

Part of the Statistics for ML section of Coddy's Machine Learning journey. Lesson 42 of 64.

Is a new model, page or keyboard better? Compare the groups by their difference in means: one group's mean minus the other's. Ten typists each tried one layout:

typing = pd.DataFrame({
    "layout": ["Qwerty", "Dvorak", "Qwerty", "Dvorak", "Qwerty", "Dvorak", "Qwerty", "Dvorak", "Qwerty", "Dvorak"],
    "wpm": [68, 76, 74, 65, 61, 82, 79, 70, 66, 74],
})
means = typing.groupby("layout")["wpm"].mean()
print(np.round(means["Dvorak"] - means["Qwerty"], 2))

This prints 3.8: Dvorak typists averaged 3.8 more words per minute. Qwerty minus Dvorak gives -3.8, so say which group comes first.

Five Qwerty typists and five Dvorak typists as dots spread from 61 to 82 words per minute, with each group's mean as a bar, 69.6 and 73.4, and a red bracket marking the gap of 3.8 between them

Is 3.8 big? Single typists spread over 20 words per minute, so the luck of who got which keyboard could make this gap alone.

challenge icon

Challenge

Medium

Students practiced with one of two math apps. math_apps.csv has app (algo or numo), score and sets; the program reads one number column's name.

  1. Compute the numo mean minus the algo mean of that column.
  2. Let its sign pick the app ahead, and print the line below: the gap positive, the leader's mean first, all to 2 decimals.

For other students and the input score:

algo is ahead on score by 4.0 (151.0 vs 147.0)

Try it yourself

import numpy as np
import pandas as pd

students = pd.read_csv("math_apps.csv")
column = input()

# Write your code below
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Statistics for ML

Practice on your own: Online Python compiler