LS 40 (Life Science) Homework 1 Solutions (Lecture 1 W21)updated in Jan 2021
Homework 1 Solutions By Ashley (Adapted from previous solutions) updated in January 2021 by Ana Gomez points: 21 completion points, 5 accuracy points = 26 points total 1. The age distribution of f irst-time mothers in the United States has changed greatly over the last forty years, so we’d like you to analyze a representative dataset of ages of first time mothers in 1980 and 2016. If you’d like to know more about this phenomenon, see the New York Times article “ The Age That Women Have Babies: How a Gap Divides America .” For each dataset (provided in the turn-in sheet), do the following steps: a. Use Python to plot a dot plot, beeswarm plot, histogram, violin plot, and boxplot. (5 points for completion) In [1]: # Import Python libraries %matplotlib inline import matplotlib as mat import seaborn as sns import numpy as np import t as plt # for displaying plots side by side in subplots In [2]: # Dataset for Homework 1: Representative dataset of age of first time mothers in USA in 1980 and 2016 ages1980 = [23,32,20,27,28,20,29,25,19,19,19,27,27,25,24,18,17,20,22,17,22,20, ages2016 = [21,29,41,23,35,16,18,19,26,29,33,19,18,28,21,18,24,31,37,31,27,36, 18,40,33,27,25,26,22,29,27,30,29,30,25,28,24,23,17,19,36,18,29,22,25,20,20,34, In [21]: # Dot plots p1 = plot(data=ages1980,jitter=True) (ylabel = "Age of First-Time Mothers", title = "1980") Homework 1 Solutions (Lecture 1 W21) 2/5/21, 1:02 AM file:///Users/ana/Downloads/Assignment%20Solutions%2021W/Homew…0Solutions/Homework%201%20Solutions%20(Lecture%201%20W21).html Page 2 of 13 [Text(0, 0.5, 'Age of First-Time Mothers'), Text(0.5, 0, ''), Text(0.5, 1.0, '1980')] [Text(0, 0.5, 'Age of First-Time Mothers'), Text(0.5, 1.0, '2016')]
Written for
- Institution
- University Of California - Los Angeles
- Course
- LS 40 Popular Culture in Modern Chinese Societies
Document information
- Uploaded on
- July 8, 2021
- Number of pages
- 13
- Written in
- 2021/2022
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
ls 40 life science homework 1 solutions lecture 1 w21updated in jan 2021
-
ls 40 life science
-
ls 40 life science homework 1 solutions