Question: Task 1 Simulation A. Use np.random.randint to simulate age data for 100 adults, whose age range from 18 to 36. Then, calculate basic descriptive statistics
Task 1
Simulation
A. Use np.random.randint to simulate age data for 100 adults, whose age range from 18 to 36.
Then, calculate basic descriptive statistics (mean, median, standard deviation) for your simulated data.
B. Repeat the process in Question A, except the age range is now 27 to 54.
C. Visualization
Display each age grouop using a side-by-side boxplot. You MUST use either matplotlib or seaborn library for this task.
Note: question A and B has been answered.
For question C, my code is displayed below.
import matplotlib.pyplot as plt import seaborn as sns sns.boxplot(x='age_group', y='age', data=df, width=0.4, color='lightblue') plt.show()
Note: This was the error message i got for question C
NameError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_12632\610683687.py in2 import matplotlib.pyplot as plt 3 import seaborn as sns ----> 4 sns.boxplot(x='age_group', y='age', data=df, width=0.4, color='lightblue') 5 plt.show() 6 NameError: name 'df' is not defined
Task 2
How does your answer in Part 1C compare to Part 1B? Does this make sense and why?
1c. code: compute_lower_bound(500, 25, 7.5, z=2.576) Answer: 24.13598333349408
1b. code: compute_lower_bound(500, 25, 7.5) Answer: 24.34259601461506
How does your answer in Part 1F compare to Part 1E? Does this make sense and why?
1f. code: shorthand_ci(500, 25, 7.5, 2.576) Answer: (24.13598333349408, 25.86401666650592)
1e. code: shorthand_ci(500, 25, 7.5, 1.96) Answer: (24.34259601461506, 25.65740398538494)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
