MATH 314 Quiz 17
Given on 2025-12-08
Please submit a jupyter notebook to the Quiz 17 GitHub repository by 1.55pm.
There are exactly 5 things wrong in each code chuck of each of the problems below. Wrong can be either
-
the code won't work, or
-
the code is unreasonable and a strictly superior choice should be made.
Please cross out the wrong characters and write an ordered, comma
separated list of replacement characters after the comment #. If you
don't know the correct Python syntax for the replacement characters
you want, make something not unreasonable up for partial credit.
You should assume the following code precedes each code chunk in each question. Otherwise, the code chunks are independent across problems; no code in one question's code chunk informs code in another question's code chunk.
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import statsmodels.api as sm
import statsmodels.formula.api as smf
import scipy.stats as st
url = "https://raw.githubusercontent.com/roualdes/data/refs/heads/master/finches.csv"
df = pd.read_csv(url)
-
Calculate a 95% confidence interval of the variable
beakwidth.x = df["bill_depth_mm"] xbar = np.mean(y) N = np.size(x) se = np.sqrt(np.var(x)) t = st.t(df = N - 1).ppf([0.025, 0.95]) xbar + t * se -
Plot the data, marking the islands with different colors, as if you were setting up the plot for a linear regression model where you will predict
taillengthusingbeakwidth.for gdf in df.groupby(["island"]): plt.scatter(gdf["taillength"], gdf["beakwidth"], label = name[0]) plt.xlabel("taillength") plt.xlabel("beakwidth") plt.legend()