hw03_sol.pdf - hw03_master Homework 3 Tables and Charts Reading Textbook chapters 5(http\/www.inferentialthinking.com\/chapters\/05\/tables.html and

hw03_sol.pdf - hw03_master Homework 3 Tables and Charts...

This preview shows page 1 - 4 out of 14 pages.

9/7/2017 hw03_master 1/14 Homework 3: Tables and Charts Reading: Textbook chapters 5 () and 6 () . Please complete this notebook by filling in the cells provided. Before you begin, execute the following cell to load the provided tests. Each time you start your server, you will need to execute this cell again to load the tests. In [ ]: # Don't change this cell; just run it. import numpy as np from datascience import * % matplotlib inline import matplotlib.pyplot as plots plots.style.use('fivethirtyeight') from client.api.notebook import Notebook ok = Notebook('hw03.ok') _ = ok.auth(inline= True ) **Important**: The `ok` tests don't usually tell you that your answer is correct. More often, they help catch careless mistakes. It's up to you to ensure that your answer is correct. If you're not sure, ask someone (not for the answer, but for some guidance about your approach). 1. Differences between Universities, Part II
Image of page 1
9/7/2017 hw03_master 2/14 Question 1. Suppose you're choosing a university to attend, and you'd like to quantify how dissimilar any two universities are. You rate each university you're considering on several numerical traits. You decide on a very detailed list of 1000 traits, and you measure all of them! Some examples: The cost to attend (per year) The average Yelp review of nearby Thai restaurants The USA Today ranking of the Medical school The USA Today ranking of the Engineering school You decide that the dissimilarity between two universities is the total of the differences in their traits. That is, the dissimilarity is: the sum of the absolute values of the 1000 differences in their trait values. In the next cell, we've loaded arrays containing the 1000 trait values for Stanford and Berkeley. Compute the dissimilarity (according to the above method) between Stanford and Berkeley. Call your answer dissimilarity . Use a single line of code to compute the answer. Note: The data we're using aren't real -- we made them up for this exercise, except for the cost-of-attendance numbers, which we estimated for a student from a median-income family living in California using this tool () . In [2]: stanford = Table.read_table("stanford.csv").column("Trait value") berkeley = Table.read_table("berkeley.csv").column("Trait value") dissimilarity = sum(abs(stanford - berkeley)) #SOLUTION dissimilarity In [3]: _ = ok.grade('q1_1') Question 2. Identify all the subexpressions in your answer to the previous question, excluding the whole expression itself. Write each on its own line. Before each one, write a one-line comment describing the value of the subexpression, including what type of value it is. We've written the first one for you. (It should appear somewhere in your answer to the previous question!) Out[2]: 14060.558701067917 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Running tests --------------------------------------------------------------------- Test summary Passed: 1 Failed: 0 [ooooooooook] 100.0% passed
Image of page 2
9/7/2017 hw03_master 3/14 In [ ]:
Image of page 3
Image of page 4

You've reached the end of your free preview.

Want to read all 14 pages?

  • Fall '17
  • trait values, different measured trait

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors