{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Homework 9 - Chapter 14" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Due Date: Friday, April 10th no later than 11:59 p.m.\n", "- Partner Information: You must complete this assignment with exactly one classmate. To give you experience working with someone different, your teammate will be assigned during class on Monday, April 6th.\n", "- Submission Instructions: Upload your solution, entitled \n", "**YourFirstName-YourLastName-PartnerFirstName-PartnerLastName-Homework9.ipynb** to the Canvas Homework 9 Dropbox. Note: If you \n", "work with a partner, only one person needs to submit a solution. If you both submit a solution, the submission that will be graded is the one \n", "from the partner whose last name comes alphabetically first.\n", "- Deadline Reminder: Once the submission deadline passes, Canvas will no longer accept your submission and you will no longer be able to earn credit. \n", "Thus, if you are not able to fully complete the assignment, submit whatever you have before the deadline so that partial credit can be earned." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Starting Code" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from datascience import *\n", "import matplotlib.pyplot as plots\n", "%matplotlib inline\n", "import numpy as np\n", "from scipy import stats" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Download the *video-game-sales.csv* file\n", "into the same directory as this Jupyter notebook." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Place the csv file in the same directory as your solution\n", "sales = Table().read_table(\"video-game-sales.csv\")\n", "sales.show(3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 1a - 1 point" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add a column entitled **SU Sales** that shows sales in standard units. Sort this column\n", "into descending order and then display the first three entries\n", "of the modified table." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Place answer here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 1b - 1 point" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Calculate and display the mean of the SU Sales in the following format where d is a digit:\n", "\n", "*The mean SU sales = d.ddd*" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Place answer here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 1c - 1 point" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Explain carefully why you see the answer that you do for Question 1b." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Explanation -**" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 1d - 1 point" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Display the highest and lowest value of SU Sales in the following format\n", "where d is a digit. Your solution should take advantage of the already sorted\n", "sales table in an efficient and general manner. In other words, do not do\n", "any more sorting and make sure your solution works for a table of any size.\n", "\n", "*The highest SU Sales = d.dd* \n", "*The lowest SU Sales = d.dd*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 2 - 4 points" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Complete the function below using basic python constructs. The function should\n", "be efficient and the only library call that is allowed is to stats.norm.cdf." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# -------------------------------------------\n", "# middle_percent: a number between 0.0 and 100.0\n", "# precision: the desired number of significant digits\n", "# -------------------------------------------\n", "# Returns a float between 0.0 and 1.0 (answer) such that\n", "# cdf(answer) - cdf(-answer) covers *middle_percent* of the data of a\n", "# normal curve and is within 1/(10**precision) of the true answer.\n", "# ----------------------------------------------\n", "\n", "def estimate_cdf(middle_percent, precision):\n", " # Missing code goes here\n", " pass" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# You may assume the user will enter valid data\n", "# Example: If the user enters 60 and then 3, the answer should be close to 0.8408203125\n", "\n", "print(\"Consider a normal curve.\")\n", "print(\"You want to determine the cdf value that captures a specified percent of the middle values.\")\n", "\n", "middle_percent = float(input(\"Desired middle percent of normal curve data [0.0 - 100.0]: \")) / 100\n", "precision = int(input(\"Desired significant digits of estimate accuracy [1 - 5]: \"))\n", "\n", "answer = estimate_cdf(middle_percent, 1 / 10**precision)\n", "print(\"The desired cdf value =\", answer)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Question 3 - 2 Points" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Develop an insightful visualization that uses the provided csv file, Chapter 14 knowledge, and any \n", "other data science knowledge that you have previously learned. Explain your visualization and what \n", "makes it insightful." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Place answer here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Explanation -**" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.14.2" } }, "nbformat": 4, "nbformat_minor": 4 }