繪製常態分配
某連鎖餐廳蒐集了顧客消費資料。結果顯示消費大致呈現常態分配,平均為 $3.15,每位顧客的標準差為 $1.50。
本練習屬於課程
Python 機率基礎
練習說明
- 從
scipy.stats匯入norm,將matplotlib.pyplot匯入為plt,並將seaborn匯入為sns。 - 產生一個平均為
3.15、標準差為1.5的常態分配樣本。 - 繪製產生的樣本圖。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Import norm, matplotlib.pyplot, and seaborn
from scipy.stats import ____
import matplotlib.pyplot as ____
import seaborn as ____
# Create the sample using norm.rvs()
sample = norm.____(loc=____, scale=____, size=10000, random_state=13)
# Plot the sample
sns.____(____)
plt.show()