Visualizing samples
You saw that a single sample can give an unreliable point estimate. To investigate this you decide to take 100 samples of 90 consecutive days of BTC trading data. For each of these 100 samples you compute the percent change in BTC over that time period. You then want to plot this data as a histogram to understand the sampling distribution.
Although these visualizations can be created with plt.hist()
, for this exercise, you'll practice using the .plot()
argument on a DataFrame, with the arguments bins
and density
.
The 100 samples of percent change has already been loaded for you in btc_pct_change_list
. This is a list of length 100 with each entry being the percent change in BTC for one of the 100 samples chosen. Matplotlib has also been imported as plt
.
This exercise is part of the course
Foundations of Inference in Python
Exercise instructions
- Plot a histogram of BTC percent change with 15
bins
with the y-values displaying thedensity
, rather than the count. - Set the x-axis label to "BTC 90-day percent change".
- Set the y-axis label to "Percent of samples".
- Set the title to "Sampling distribution of BTC 90-day change".
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Plot a histogram of percent changes
plt.____(____, bins=____, density=____)
# Set the x-axis label
plt.____('BTC 90-day percent change')
# Set the y-axis label
plt.____('Percent of samples')
# Set the title
plt.____('Sampling distribution of BTC 90-day change')
plt.show()