{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "(lecture16:homework)=\n", "# Homework 16\n", "\n", "+ Type your name and email in the \"Student details\" section below.\n", "+ Develop the code and generate the figures you need to solve the problems using this notebook.\n", "+ For the answers that require a mathematical proof or derivation you can either:\n", " \n", " - Type the answer using the built-in latex capabilities. In this case, simply export the notebook as a pdf and upload it on gradescope; or\n", " - You can print the notebook (after you are done with all the code), write your answers by hand, scan, turn your response to a single pdf, and upload on gradescope.\n", "\n", "+ The total homework points are 100. Please note that the problems are not weighed equally.\n", "\n", "```{note}\n", "+ This is due before the beginning of the next lecture.\n", "+ Please match all the pages corresponding to each of the questions when you submit on gradescope.\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Student details\n", "\n", "+ **First Name:**\n", "+ **Last Name:**\n", "+ **Email:**" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "tags": [ "hide-input" ] }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "import seaborn as sns\n", "sns.set(rc={\"figure.dpi\":100, 'savefig.dpi':300})\n", "sns.set_context('notebook')\n", "sns.set_style(\"ticks\")\n", "from IPython.display import set_matplotlib_formats\n", "set_matplotlib_formats('retina', 'svg')\n", "import numpy as np\n", "import scipy.stats as st\n", "import pandas as pd\n", "import requests\n", "import os\n", "def download(url, local_filename=None):\n", " \"\"\"\n", " Downloads the file in the ``url`` and saves it in the current working directory.\n", " \"\"\"\n", " data = requests.get(url)\n", " if local_filename is None:\n", " local_filename = os.path.basename(url)\n", " with open(local_filename, 'wb') as fd:\n", " fd.write(data.content)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Problem 1 - Explaining the Challenger disaster\n", "On January 28, 1986, the [Space Shuttle Challenger](https://en.wikipedia.org/wiki/Space_Shuttle_Challenger_disaster) disintegrated after 73 seconds from launch.\n", "The failure can be traced on the rubber O-rings which were used to seal the joints of the solid rocket boosters (required to force the hot, high-pressure gases generated by the burning solid propelant through the nozzles thus producing thrust).\n", "\n", "It turns out that the performance of the O-ring material was particularly sensitive on the external temperature during launch.\n", "This [dataset](https://raw.githubusercontent.com/PredictiveScienceLab/data-analytics-se/master/homework/challenger_data.csv) contains records of different experiments with O-rings recorded at various times between 1981 and 1986.\n", "Download the data the usual way (either put them on Google drive or run the code cell below)." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "url = 'https://raw.githubusercontent.com/PurdueMechanicalEngineering/me-297-intro-to-data-science/master/data/challenger_data.csv'\n", "download(url)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Even though this is a csv file, you should load it with pandas because it contains some special characters." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Date | \n", "Temperature | \n", "Damage Incident | \n", "
---|---|---|---|
0 | \n", "04/12/1981 | \n", "66 | \n", "0 | \n", "
1 | \n", "11/12/1981 | \n", "70 | \n", "1 | \n", "
2 | \n", "3/22/82 | \n", "69 | \n", "0 | \n", "
3 | \n", "6/27/82 | \n", "80 | \n", "NaN | \n", "
4 | \n", "01/11/1982 | \n", "68 | \n", "0 | \n", "
5 | \n", "04/04/1983 | \n", "67 | \n", "0 | \n", "
6 | \n", "6/18/83 | \n", "72 | \n", "0 | \n", "
7 | \n", "8/30/83 | \n", "73 | \n", "0 | \n", "
8 | \n", "11/28/83 | \n", "70 | \n", "0 | \n", "
9 | \n", "02/03/1984 | \n", "57 | \n", "1 | \n", "
10 | \n", "04/06/1984 | \n", "63 | \n", "1 | \n", "
11 | \n", "8/30/84 | \n", "70 | \n", "1 | \n", "
12 | \n", "10/05/1984 | \n", "78 | \n", "0 | \n", "
13 | \n", "11/08/1984 | \n", "67 | \n", "0 | \n", "
14 | \n", "1/24/85 | \n", "53 | \n", "1 | \n", "
15 | \n", "04/12/1985 | \n", "67 | \n", "0 | \n", "
16 | \n", "4/29/85 | \n", "75 | \n", "0 | \n", "
17 | \n", "6/17/85 | \n", "70 | \n", "0 | \n", "
18 | \n", "7/29/85 | \n", "81 | \n", "0 | \n", "
19 | \n", "8/27/85 | \n", "76 | \n", "0 | \n", "
20 | \n", "10/03/1985 | \n", "79 | \n", "0 | \n", "
21 | \n", "10/30/85 | \n", "75 | \n", "1 | \n", "
22 | \n", "11/26/85 | \n", "76 | \n", "0 | \n", "
23 | \n", "01/12/1986 | \n", "58 | \n", "1 | \n", "
24 | \n", "1/28/86 | \n", "31 | \n", "Challenger Accident | \n", "