How does the current effect depend on lane position?
To quantify the effect of lane number on performance, perform a linear regression on the f_13
versus lanes
data. Do a pairs bootstrap calculation to get a 95% confidence interval. Finally, make a plot of the regression. The arrays lanes
and f_13
are in your namespace.
Note that we could compute error bars on the mean fractional differences and use them in the regression, but that is beyond the scope of this course.
Cet exercice fait partie du cours
Case Studies in Statistical Thinking
Instructions
- Compute the slope and intercept of the
f_13
versuslanes
line usingnp.polyfit()
. - Use
dcst.draw_bs_pairs_linreg()
to get 10,000 bootstrap replicates of the slope and intercept, storing them respectively inbs_reps_slope
andbs_reps_int
. - Use the bootstrap replicates to compute a 95% confidence interval for the slope.
- Print the slope and 95% confidence interval to the screen. This has been done for you.
- Using
np.array()
, generate x-values to use for the plot of the bootstrap lines.x
should go from1
to8
. - The plot is already populated with the data. Write a
for
loop to add 100 bootstrap lines to the plot using the keyword argumentscolor='red'
,alpha=0.2
, andlinewidth=0.5
.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Compute the slope and intercept of the frac diff/lane curve
____, ____ = ____
# Compute bootstrap replicates
bs_reps_slope, bs_reps_int = ____
# Compute 95% confidence interval of slope
conf_int = ____
# Print slope and confidence interval
print("""
slope: {0:.5f} per lane
95% conf int: [{1:.5f}, {2:.5f}] per lane""".format(slope, *conf_int))
# x-values for plotting regression lines
x = ____
# Plot 100 bootstrap replicate lines
for i in ____:
_ = ____(____, ____[i] * ____ + ____[i],
color='red', alpha=0.2, linewidth=0.5)
# Update the plot
plt.draw()
plt.show()