開始使用免費開始

這個參數為什麼是最佳的?

現在從一個指數分佈取樣,其 \(\tau\) 為最佳 \(\tau\) 的 2 倍。接著再做一次,但讓 \(\tau\) 只剩一半。將這些樣本的 CDF 畫出來,並與你的資料重疊比較。你會看到它們無法同樣好地重現資料。因此,你用平均無無安打間隔時間計算出的 \(\tau\) 是最佳的,因為它最能重現資料。

注意:在本題與之後所有練習中,隨機數產生器都已經預先設好種子,幫你省去設定的步驟。

本練習屬於課程

Statistical Thinking in Python(第 2 部分)

檢視課程

練習說明

  • 從參數為 \(\tau_{1/2}\) = tau/2 的指數分佈取 10000 個樣本。
  • 從參數為 \(\tau_{2}\) = 2*tau 的指數分佈取 10000 個樣本。
  • 使用你的 ecdf() 函式,為這兩組樣本各自產生 CDF。
  • 把這兩條 CDF 作為線條加到你的圖上。這部分已為你完成,按下 送出答案 以查看圖表!

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Plot the theoretical CDFs
plt.plot(x_theor, y_theor)
plt.plot(x, y, marker='.', linestyle='none')
plt.margins(0.02)
plt.xlabel('Games between no-hitters')
plt.ylabel('CDF')

# Take samples with half tau: samples_half
samples_half = ____

# Take samples with double tau: samples_double
samples_double = ____

# Generate CDFs from these samples
x_half, y_half = ____
x_double, y_double = ____

# Plot these CDFs as lines
_ = plt.plot(x_half, y_half)
_ = plt.plot(x_double, y_double)

# Show the plot
plt.show()
編輯並執行程式碼