Homework 1 (Due 10/4/2024 at 11:59pm)

Contents

Homework 1 (Due 10/4/2024 at 11:59pm)#

Name:

ID:

This homework prepares you for the submission workflow in this course.

Submission instruction:

  • Download the file as .ipynb (see top right corner on the webpage).

  • Answer the questions in the .ipynb file.

  • Before submission, make sure to rerun all cells by clicking Kernel -> Restart & Run All and check all the outputs.

  • Upload the .ipynb file to Gradescope.

Q1#

Formatting Juptyer Notebook

Refer to the wiki page https://en.wikipedia.org/wiki/Fundamental_theorem_of_calculus

  • Write “Fundamental Theorem of Calculus” in bold font. See Emphasis in Markdown

  • Type the theorem (wiki page - Formal statements - First part) in markdown. Use latex to write the mathematical expression. See writing math expressions.

Q2#

We will use the pandas library in this course.

If pandas is not installed, install it using the following command in a code cell:

%conda install pandas

or

%pip install pandas

Check if pandas is installed by running the following code cell. If it is not installed, an error will be raised.

import pandas as pd

Q3#

Download the penguins dataset from the internet. We will read the dataset into a pandas dataframe.

  • Put the penguins.csv file in the same directory as the notebook

  • Otherwise you need to specify the path to the file e.g. pd.read_csv('/path/to/penguins.csv')

  • If you’re using cloud-based Jupyter notebook, you need to upload the dataset to the notebook environment.

Run the following code cell to load the dataset into a pandas dataframe. If successful, a table will be displayed.

Reference: how to get the path of a file on Mac, on Windows

# you can get the path of the current directory where the notebook is located by using the following command
# !pwd
import pandas as pd
df = pd.read_csv('penguins.csv')
df.head()

Q4#

We will use some libraries for plotting, such as matplotlib and seaborn.

If seaborn is not installed, install it using the following command in a code cell:

%conda install seaborn

or

%pip install seaborn

Check if seaborn is installed by running the following code cell. If it is not installed, an error will be raised. If successful, a plot will be displayed.

import seaborn as sns

# Load an example dataset with long-form data
fmri = sns.load_dataset("fmri")

# Plot the responses for different events and regions
sns.lineplot(x="timepoint", y="signal",
             hue="region", style="event",
             data=fmri)