5. Here is some data on the US government’s discretionary budget (things that are not mandatory, like Social security, Medicare, interest on the national debt) Source: https://www.thebalance.com/how-trump-amended-obama-budget-4128986. I have summarized it in a csv file (it’s possible that there are errors in the data, since I typed these all in manually, but this shouldn’t affect your analysis). You can use these commands to download the data and analyze it:
import pandas as pd import numpy as np df = pd.read_csv("https://raw.githubusercontent.com/mathalexchen/Data/main/budget.csv") print(df) year2019 = np.array(df["2019"]) # extract a particular column; convert to a numpy array department = np.array(df["Department"]) education = np.array(df.loc[1,:]) # extract a particular row:
# 0 for defense, 1 for education, etc.
Answer the following questions (you may also use a spreadsheet program instead of python, if you prefer–just go to the following link to get the data: https://raw. githubusercontent.com/mathalexchen/Data/main/budget.csv). Be sure to either share your code or write down the commands you used to generate your results.
a) Make a pie chart of the 2019 budget and label the slices of the pie accordingly.
b) Which government agency (of the ones listed) had their budget expe- rience the highest percentage growth from 2007 to 2019?
c) Is it safe to conclude from this data that Defense is where most discretionary spending goes? Note: I don’t think there’s a “correct” answer here; just make sure you present some analysis and justify it.
6. Given a list of numbers, print the ordered pair (a, b) such that the absolute value of the difference |a − b| is the largest. For example, if nums = [1, 5, 2, 9, -2], then print (9, -2) or (-2, 9), since these result in the largest absolute value of the difference —9 - (-2)— = 11.
7. (bonus question, 10 points) Suppose 1 out of 1000 people in the LA area are infected with Covid. Suppose also that there is a rapid test with the following properties:
– 90% of infected people test positive. – 99% of non-infected test negative.
If someone tests positive, what is the probability that this person has Covid? You may do this problem analytically or by simulation. If you write code, here are some tips:
2
• – Run many trials, probably 1,000,000. • – On each trial, simulate the probability that someone has Covid (a 0.001 proba-
bility).
• – Then if the person has Covid, simulate the probability that the person tests positive (0.9 probability).
• – If the person does not have Covid, simulate the probability that the person tests positive (1 - 0.99 = 0.01 probability).
• – Count the number of times that someone tested positive and has Covid; also count the number of times someone tested positive; dividing the former by the latter gives the probability you’re looking for.
• – You can ignore any times the test comes back negative
WE HAVE DONE THIS ASSIGNMENT BEFORE, WE CAN ALSO DO IT FOR YOU
GET SOLUTION FOR THIS ASSIGNMENT, Get Impressive Scores in Your Class
CLICK HERE TO MAKE YOUR ORDER on US government’s discretionary budget
Comments
Post a Comment