Homework 2 Notebook#
In this notebook, we will revisit the football data from last week in order to practice calculating the mean, median, and mode of some distributions.
# As always, Let's start with importing our packages
import os
import numpy as np
import scipy
import matplotlib
import matplotlib.pyplot as plt
from astropy.table import Table
# We can beautify our plots by changing the matpltlib setting a little
plt.rcParams['font.size'] = 18
plt.rcParams['axes.linewidth'] = 2
Show code cell content
# Don't worry about this cell, it's just to make the notebook look a little nicer.
try:
import google.colab
IN_COLAB = True
except ImportError:
IN_COLAB = False
# Get the directory right
if IN_COLAB:
from google.colab import drive
drive.mount('/content/drive/')
os.chdir('/content/drive/Shareddrives/AST207/data')
else:
if not os.path.exists("../../../_static/ObsAstroData/"):
os.makedirs("../../../_static/ObsAstroData/")
os.chdir('../../../_static/ObsAstroData/')
# Read the catalog of the football players
cat = Table.read('./players_age.csv')
Again, we can check all the column names with cat.colnames
.
cat.colnames
['nflId',
'height',
'weight',
'birthDate',
'collegeName',
'officialPosition',
'displayName',
'height_inches',
'age']
1. Calculate the mean, median, and mode of the player height (in inches).#
## Your answer goes here
2. Are the three numbers different? If so, why? If not, why not?#
## Your answer goes here
3. Make a histogram of the player height in the same units. Do your answers make sense?#
## Your answer goes here
4. Calculate the mean, median, and mode of the player age. Again histogram the player age and determine if your answers make sense.#
## Your answer goes here
Extra credit: find height and age data for typical people in the United States and compare our statistics with those of football players. How can you compare the distributions?#
## Your answer goes here