Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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!!

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions