Get startedGet started for free

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.

This exercise is part of the course

Case Studies in Statistical Thinking

View Course

Exercise instructions

  • Compute the slope and intercept of the f_13 versus lanes line using np.polyfit().
  • Use dcst.draw_bs_pairs_linreg() to get 10,000 bootstrap replicates of the slope and intercept, storing them respectively in bs_reps_slope and bs_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 from 1 to 8.
  • The plot is already populated with the data. Write a for loop to add 100 bootstrap lines to the plot using the keyword arguments color='red', alpha=0.2, and linewidth=0.5.

Hands-on interactive exercise

Have a go at this exercise by completing this sample 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()
Edit and Run Code