Assessing the growth rate
To compute the growth rate, you can do a linear regression of the logarithm of the total bacterial area versus time. Compute the growth rate and get a 95% confidence interval using pairs bootstrap. The time points, in units of hours, are stored in the numpy
array t
and the bacterial area, in units of square micrometers, is stored in bac_area
.
This exercise is part of the course
Case Studies in Statistical Thinking
Exercise instructions
- Compute the logarithm of the bacterial area (
bac_area
) usingnp.log()
and store the result in the variablelog_bac_area
. - Compute the slope and intercept of the semilog growth curve using
np.polyfit()
. Store the slope in the variablegrowth_rate
and the intercept inlog_a0
. - Draw 10,000 pairs bootstrap replicates of the growth rate and log initial area using
dcst.draw_bs_pairs_linreg()
. Store the results ingrowth_rate_bs_reps
andlog_a0_bs_reps
. - Use
np.percentile()
to compute the 95% confidence interval of the growth rate (growth_rate_bs_reps
). - Print the growth rate and confidence interval to the screen. This has been done for you, so hit 'Submit Answer' to view the results!
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Compute logarithm of the bacterial area: log_bac_area
log_bac_area = ____
# Compute the slope and intercept: growth_rate, log_a0
____, ____ = ____
# Draw 10,000 pairs bootstrap replicates: growth_rate_bs_reps, log_a0_bs_reps
____, ____ = ____(
____, ____, size=____
)
# Compute confidence intervals: growth_rate_conf_int
growth_rate_conf_int = ____
# Print the result to the screen
print("""
Growth rate: {0:.4f} 1/hour
95% conf int: [{1:.4f}, {2:.4f}] 1/hour
""".format(growth_rate, *growth_rate_conf_int))