Plotting the growth curve
You saw in the previous exercise that the confidence interval on the growth curve is very tight. You will explore this graphically here by plotting several bootstrap lines along with the growth curve. You will use the plt.semilogy()
function to make the plot with the y-axis on a log scale. This means that you will need to transform your theoretical linear regression curve for plotting by exponentiating it.
This is a part of the course
“Case Studies in Statistical Thinking”
Exercise instructions
- Plot the data points using
plt.semilogy()
. Thenumpy
arrayst
andbac_area
are again in your namespace. - Use
np.array()
to generate time values for plotting the bootstrap lines. Call thist_bs
. The time should go from 0 to 14 hours. - Write a
for
loop to plot regression lines corresponding to the first 100 pairs bootstrap replicates. Thenumpy
arraysgrowth_rate_bs_reps
andlog_a0_bs_reps
that you computed in the last exercise are in your namespace.- Compute the growth curve by exponentiating the linear regression line using
np.exp()
. - Plot the theoretical line using
plt.semilogy()
with keyword argumentslinewidth=0.5
,alpha=0.05
, andcolor='red'
.
- Compute the growth curve by exponentiating the linear regression line using
- Label the axes and show your plot. Appropriate labels for the respective x and y axes are
'time (hr)'
and'area (sq. µm)'
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Plot data points in a semilog-y plot with axis labeles
_ = ____(____, ____, marker='.', linestyle='none')
# Generate x-values for the bootstrap lines: t_bs
t_bs = ____([____, ____])
# Plot the first 100 bootstrap lines
for i in range(____):
y = ____(____[i] * ____ + ____[i])
_ = ____(____, ____, linewidth=____, alpha=____, color=____)
# Label axes and show plot
_ = plt.xlabel('____')
_ = plt.ylabel('____')
____
This exercise is part of the course
Case Studies in Statistical Thinking
Take vital steps towards mastery as you apply your statistical thinking skills to real-world data sets and extract actionable insights from them.
To begin, you'll use two data sets from Caltech researchers to rehash the key points of Statistical Thinking I and II to prepare you for the following case studies!
Exercise 1: Activity of zebrafish and melatoninExercise 2: EDA: Plot ECDFs of active bout lengthExercise 3: Interpreting ECDFs and the storyExercise 4: Bootstrap confidence intervalsExercise 5: Parameter estimation: active bout lengthExercise 6: Permutation and bootstrap hypothesis testsExercise 7: Permutation test: wild type versus heterozygoteExercise 8: Bootstrap hypothesis testExercise 9: Linear regressions and pairs bootstrapExercise 10: Assessing the growth rateExercise 11: Plotting the growth curveWhat is DataCamp?
Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.