EDA: Plot ECDFs of active bout length
An active bout is a stretch of time where a fish is constantly moving. Plot an ECDF of active bout length for the mutant and wild type fish for the seventh night of their lives. The datasets are in the numpy
arrays bout_lengths_wt
and bout_lengths_mut
. The bout lengths are in units of minutes.
This exercise is part of the course
Case Studies in Statistical Thinking
Exercise instructions
- Import the module
dc_stat_think
asdcst
so you have its functions available. - Generate the x and y values for plotting the ECDF of the wild type fish (
bout_lengths_wt
) usingdcst.ecdf()
. Store the result innumpy
arrays namedx_wt
andy_wt
. - Do the same for the the mutant fish (
bout_lengths_mut
), storing the result innumpy
arrays namedx_mut
andy_mut
. - Use
plt.plot()
to plot the two ECDFs as dots on the same plot. Be sure to specify the keyword argumentsmarker='.'
andlinestyle='none'
. - Show your plot using
plt.show()
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import the dc_stat_think module as dcst
____
# Generate x and y values for plotting ECDFs
x_wt, y_wt = ____
____, ____ = ____
# Plot the ECDFs
_ = ____(____, ____, ____='.', linestyle='____')
_ = ____(____, ____, ____='.', linestyle='____')
# Make a legend, label axes, and show plot
_ = plt.legend(('wt', 'mut'))
_ = plt.xlabel('active bout length (min)')
_ = plt.ylabel('ECDF')
____