Question: Need help with these Python/Numpy/Pandas problems please!! import numpy as np import pandas as pd np.random.seed (0) p_measles = 0.05 - Marginal probability of measles

Need help with these Python/Numpy/Pandas problems please!!

Need help with these Python/Numpy/Pandas problems please!! import numpy as np import

import numpy as np import pandas as pd np.random.seed (0) p_measles = 0.05 - Marginal probability of measles p_pos_if_measles = 0.90 - Probability of a positive test given measles p_pos_if_okay = 0.05 - Probability of a negative test given no measles n = 10000 - Total number of people in simulation has_measles = np.random.choice ([True, False), n) tests_positive = np.random.choice ([True, False], n) 1. First we simulate who has measles and who does not. Using n and p_measles, randomly initialize the has_measles array. 2. Using has_measles, set the value of num_measles to the number of True values in has_measles. 3. Using variable n, initialize the tests_positive array to all False values 4. Now we simulate, for the people with measles, whether they test positive for measles or not. Using p_pos_if_measles, has_measles, and num_measles, randomly initialize the values of tests_positive for people with measles. Hint: think about a slightly easier problem: set values in tests_positive to True if they correspond to elements in has_measles that are True. 5. Now we simulate, for the people without measles, whether they test positive for measles or not. Using p_pos_if_okay, has_measles, n, and num_measles, randomly initialize the values of tests_positive for people without measles. import numpy as np import pandas as pd np.random.seed (0) p_measles = 0.05 - Marginal probability of measles p_pos_if_measles = 0.90 - Probability of a positive test given measles p_pos_if_okay = 0.05 - Probability of a negative test given no measles n = 10000 - Total number of people in simulation has_measles = np.random.choice ([True, False), n) tests_positive = np.random.choice ([True, False], n) 1. First we simulate who has measles and who does not. Using n and p_measles, randomly initialize the has_measles array. 2. Using has_measles, set the value of num_measles to the number of True values in has_measles. 3. Using variable n, initialize the tests_positive array to all False values 4. Now we simulate, for the people with measles, whether they test positive for measles or not. Using p_pos_if_measles, has_measles, and num_measles, randomly initialize the values of tests_positive for people with measles. Hint: think about a slightly easier problem: set values in tests_positive to True if they correspond to elements in has_measles that are True. 5. Now we simulate, for the people without measles, whether they test positive for measles or not. Using p_pos_if_okay, has_measles, n, and num_measles, randomly initialize the values of tests_positive for people without measles

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!