反復サンプリング、点推定、そして推論
前の演習では、90日分の単一のサンプルを使って結論を出しました。しかし、もし「別の」90日を選んだらどうでしょう。結論は変わるでしょうか?
これを評価する1つの方法が、反復サンプリングです。データから何度もサンプルを取り、点推定を計算することで、その値がどのように変動するかを確認できます。
同じデータ btc_sp_df が読み込まれており、パッケージの Pandas は pd、NumPy は np として利用できます。
この演習はコースの一部です
Pythonで学ぶ推測の基礎
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Write a for loop which repeats the sampling ten times
for i in ____:
# Select a random starting row number
initial_row_number = ____(____(btc_sp_df.shape[0] - 90))
# Select the next 90 rows after the starting row
sample_df = ____[____:____ + ____]
# Compute the percent change in closing price of BTC and print it
btc_pct_change = (____.iloc[0][____] - ____.iloc[-1][____]) / ____.iloc[0][____]
print(btc_pct_change)