Question
In Python please People providing an organ for donation sometimes seek help from a medical consultant. These consultants assist the patient in all aspects of
In Python please
People providing an organ for donation sometimes seek help from a medical consultant. These consultants assist the patient in all aspects of the surgery. Patients might choose a consultant based in part on the historical complication rate of the consultant's clients. Consultant R tries to attract patients by noting the average complication rate for liver donor surgeries in the US is about 10%, but her clients have had only 3 complications in the 62 liver donor surgeries she has facilitated. She claims this is strong evidence that her work meaningfully contributes to reducing complications (and therefore she should be hired!).
a) Write a function (monteCarloSim) that simulates coin tossing. On each trial, the function should produce a specific number (N) of coin tosses and record the number of successes (heads). It should repeat this experiment numIter number of times. The inputs to the function should be a) probability of a success on each coin toss, b) the number of coin tosses per trial (N) and c) the number of trials. The function should return an np.array(range(numIter)) that holds the recorded number of heads for all trials (see lecture handout for tips).
b) Write a function (monteCarloTest) that uses monteCarloSim (Question a) to simulate 2000 trials of a N coin tosses. The function should take as input arguments:
H0prob: The probability of heads under the Null hypothesis
N: The number of coin throws per trial
numHeads: The number of observed coin tosses.
After getting the simulation result from monteCarloSim, the function should plot a histogram of the recorded number of heads, and mark the real measured number (numHeads) with a vertical line. The function should print out the probability that the simulated number of heads is smaller than or equal to the measured number of heads.
Use the function to evaluate the medical advisor example from the lecture: Determine the probability to get 3 complications in 62 cases if the probability of a complication in the population is known to be 10%.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started