Revist a problem you got wrong on homework 2. If you got a perfect score in homework 2, state that fact. Go through each part you missed and state what your answer was and what your mistake was. For example:
My answer used the scipy comb
function instead of factorial
.
No mistakes
I used this equation:
$$\frac{100!}{5!(100 - 5)!} \frac{95!}{5!(95 - 5)!}$$which is too high by a factor of $2$. I did not consider that which team picks first is irrelevant.
numpy
and matplotlib
, plot the exponential distribution with $\lambda = 1$, $1.5$, and $2$. Include a legend that uses $\LaTeX$If you execute the cell below, it will write the contents of the cell to a file called che116.mplstyle.
We will use this file in the future, so hold onto it. To load this style and use it, execute plt.style.use('che116.mplstyle')
. Make the following changes to the file, write it, and then plot three interesting lines on the samge graph:
View the comments in this file to learn what all the parameters do
In [5]:
%%writefile che116.mplstyle
#set the font-size and size of things
figure.figsize: 5, 3
axes.labelsize: 14.3
axes.titlesize: 15.6
xtick.labelsize: 13
ytick.labelsize: 13
legend.fontsize: 13
grid.linewidth: 1.3
lines.linewidth: 2.275
patch.linewidth: 0.39
lines.markersize: 9.1
lines.markeredgewidth: 0
xtick.major.width: 1.3
ytick.major.width: 1.3
xtick.minor.width: 0.65
ytick.minor.width: 0.65
xtick.major.pad: 9.1
ytick.major.pad: 9.1
axes.xmargin : 0
axes.ymargin : 0
#setup our colorscheme
patch.facecolor: 348ABD # blue
patch.edgecolor: EEEEEE
patch.antialiased: True
font.size: 12.0
text.color: black
axes.facecolor: E5E5E5
axes.edgecolor: bcbcbc
axes.linewidth: 1
axes.grid: False
axes.labelcolor: 555555
axes.axisbelow: True # grid/ticks are below elements (e.g., lines, text)
axes.prop_cycle: cycler('color', ['444444', '348ABD', '988ED5', '777777', 'FBC15E', '8EBA42', 'FFB5B8'])
# E24A33 : red
# 348ABD : blue
# 988ED5 : purple
# 777777 : gray
# FBC15E : yellow
# 8EBA42 : green
# FFB5B8 : pink
xtick.color: 555555
xtick.direction: out
ytick.color: 555555
ytick.direction: out
grid.color: white
grid.linestyle: - # solid line
figure.facecolor: white
figure.edgecolor: 0.50
#animation settings
animation.html : html5
Create a plot with the following properties WITHOUT using a style file:
This problem is testing your ability to turn sentences into equations, to rearrange probabilities, and to be aware of sample spaces and rv dependence.
Mammograms are a testing procedure for breast cancer. The diagnosis procedure after a mammogram is positive is incredibly complex. We'll simplify a little bit here. If a mammogram test is positive, a woman will always return for a biopsy. A biopsy is the removal and analysis of a small amount of breast tissue. If a biopsy is positive we will assume it leads to a mastectomy. The statistics from here on out are mostly correct, but biopsy does not always follow a mammogram in real life. From ages 40 to 50, 45% of women who receive annual mammograms will have a false positive and 25% have a false negative. A false negative means that a woman had invasive breast cancer but the test did not show it. A false positive means a woman had no or benign cancer. A large study of biopsies shows that biopsies are correctly diagnosed 75% of the time (the state of cancer matches the state of the biopsy), with false positives being twice as likely as false negatives. You may assume that biopsies and mammograms are conditionally independent on the presence or absence of cancer. After positive finding from a mammogram and biopsy, a mastectomy is performed which has a 0.24% probability of mortality. That mortality probability is independent of all factors. The overall probability of having invasive breast cancer is 1.5% between the ages of 40 to 50. Answer the following questions:
Answer each question first with equations and markdown (symbolically) as far as possible. You can use previous answers here or given parameters, but do not compute arithmetic until the end. Final answer may be given in Python or markdown.
In [ ]: