開始使用免費開始

等變異數

不同產業獲得創投(VC)投資的程度不一樣。不過,若你觀察到一個 VC 投資樣本在各產業間的平均投資額略有差異,是否就能合理認為這個差異在統計上顯著?這正是 ANOVA 能大顯身手的情境。然而,ANOVA 的一個關鍵前提是所有樣本群組之間具有等變異數。在本練習中,你將使用 Levene 等變異數檢定來測試這個條件。

已為你載入一個包含三個產業(Biotechnology、Enterprise Software、Health Care)投資資料的 pandas DataFrame,名稱為 investments_df。此外,套件 pandas(縮寫為 pd)、NumPy(np)、Matplotlib(plt),以及 SciPy 的 stats 套件也都已載入。

本練習屬於課程

Python 推論基礎

檢視課程

練習說明

  • 使用給定的欄位名稱,從 investments_df 分別選出各個 market 的投資金額。
  • 依下列順序對各產業配對進行 Levene 等變異數檢定:(i)Biotechnology 與 Enterprise Software,(ii)Biotechnology 與 Health Care,(iii)Enterprise Software 與 Health Care,並將其分別對應到 statistic1、statistic2、statistic3。
  • 每個檢定都回傳一個布林值,指出是否拒絕「等變異數」的虛無假設。

動手互動練習

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

# Select each industry separately
biotech_df = ____
enterprise_df = ____
health_df = ____

# Conduct Levene tests for equal variance between funding_total_usd for all pairs of industries
statistic_1, p_value_1 = ____
statistic_2, p_value_2 = ____
statistic_3, p_value_3 = ____

# Print if the p-value is significant at the 5% level
print(____)
print(____)
print(____)
編輯並執行程式碼