推論統計
為了取得追蹤青少年身體質量指數所需的重要健康資料,衛生單位向一個具全國代表性的樣本發放了青少年問卷,對象為截至 1999 年 12 月 31 日年齡介於 14 至 20 歲的青少年。資料集紀錄了年齡 Age、身高(英吋)Height_in、體重(磅)Weight_lbs、性別 Gender,以及對題目「你會如何形容自己的體重?」的自陳多選答案 describe_weight。
這份調查的清理後資料集已載入為 youth_survey_clean。在本練習中,你將計算信賴區間。
pandas、NumPy 與 SciPy 的統計套件已分別載入為 pd、np 與 st。
本練習屬於課程
使用 Python 分析問卷資料
練習說明
- 以 95% 的信賴水準,計算母體真實平均身高
Height_in的信賴區間。 - 以 99% 的信賴水準,計算母體真實平均身高
Height_in的信賴區間。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Find confidence interval for mean height with 95% confidence level
conf_95 = st.norm.interval(alpha = ____,
loc = np.mean(____),
scale = st.sem(____))
# Find confidence interval for mean height with 99% confidence level
conf_99 = st.norm.interval(alpha = ____,
loc = np.mean(____),
scale = st.sem(____))
print("conf_95 = ", conf_95)
print("conf_99 = ", conf_99)