You can call the histograms function to draw the

This preview shows page 10 - 16 out of 20 pages.

You can call thehistogramsfunction to draw the histograms!Note:More charts will be displayed when running the test cell. Please feel free to ignore the charts.
10
11
[38]:grader.check("q3_1")[38]:q3_1 passed!1.3.1Convenience samplingOne sampling methodology, which isgenerally a bad idea, is to choose players who are somehowconvenient to sample. For example, you might choose players from one team who are near yourhouse, since it’s easier to survey them. This is called, somewhat pejoratively,convenience sampling.Suppose you survey onlyrelatively newplayers with ages less than 22.(The more experiencedplayers didn’t bother to answer your surveys about their salaries.)Question 2.Assignconvenience_sampleto a subset offull_datathat contains only the rowsfor players under the age of 22.[43]:convenience_sample=full_data.where('Age', are.below(22) )convenience_sample[43]:PlayerName| Salary| Age| Team | Games | Rebounds | Assists | Steals |Blocks | Turnovers | PointsAaron Gordon| 3992040 | 19| ORL| 47| 169| 33| 21|22| 38| 243Alex Len| 3649920 | 21| PHO| 69| 454| 32| 34|105| 74| 432Andre Drummond| 2568360 | 21| DET| 82| 1104| 55| 73|153| 120| 1130Andrew Wiggins| 5510640 | 19| MIN| 82| 374| 170| 86|50| 177| 1387Anthony Bennett | 5563920 | 21| MIN| 57| 216| 48| 27|16| 36| 298Anthony Davis| 5607240 | 21| NOP| 68| 696| 149| 100|200| 95| 1656Archie Goodwin| 1112280 | 20| PHO| 41| 74| 44| 18|9| 48| 231Ben McLemore| 3026280 | 21| SAC| 82| 241| 140| 77|19| 138| 996Bradley Beal| 4505280 | 21| WAS| 63| 241| 194| 76|18| 123| 962Bruno Caboclo| 1458360 | 19| TOR| 8| 2| 0| 0|1| 4| 10… (34 rows omitted)[44]:grader.check("q3_2")[44]:q3_2 passed!12
Question 3.Assignconvenience_statsto an array of the average age and average salary ofyour convenience sample, using thecompute_statisticsfunction. Since they’re computed on asample, these are calledsample averages.[47]:convenience_stats=compute_statistics(convenience_sample)convenience_stats[47]:array([2.03636364e+01, 2.38353382e+06])13
[48]:grader.check("q3_3")[48]:q3_3 passed!Next, we’ll compare the convenience sample salaries with the full data salaries in a single histogram.To do that, we’ll need to use thebin_columnoption of thehistmethod, which indicates that allcolumns are counts of the bins in a particular column.The following cell does not require anychanges;just run it.[49]:defcompare_salaries(first, second, first_title, second_title):"""Compare the salaries in two tables."""first_salary_in_millions=first.column('Salary')/1000000second_salary_in_millions=second.column('Salary')/1000000first_tbl_millions=first.drop('Salary').with_column('Salary',,first_salary_in_millions)second_tbl_millions=second.drop('Salary').with_column('Salary',,second_salary_in_millions)max_salary=max(np.append(first_tbl_millions.column('Salary'),,second_tbl_millions.column('Salary')))bins=np.arange(0, max_salary+1,1)first_binned=first_tbl_millions.bin('Salary', bins=bins).relabeled(1,,first_title)14

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 20 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
Velkovi
Tags
Test, Pride and Prejudice, Simple random sample

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture