兩個 Poisson 變數的和
Poisson 分配有個很實用的性質:當你把多個 Poisson 分配相加,結果仍然是 Poisson 分配。
在這裡你會產生兩個 Poisson 隨機變數來驗證這件事。
本練習屬於課程
R 的機率基礎
練習說明
- 從 Poisson(1) 分配模擬 100,000 次抽樣,並將結果存為
X。 - 另行從 Poisson(2) 分配模擬 100,000 次抽樣,並將結果存為
Y。 - 將
X與Y相加,建立變數Z。 - 我們預期
Z會遵循 Poisson(3) 分配。使用compare_histograms函式,將Z與來自 Poisson(3) 的 100,000 次抽樣進行比較。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Simulate 100,000 draws from Poisson(1)
# Simulate 100,000 draws from Poisson(2)
# Add X and Y together to create Z
# Use compare_histograms to compare Z to the Poisson(3)