開始使用免費開始

估計能源研究所需的樣本數

在能源領域,研究人員經常需要評估新技術或新措施是否能提升能源效率或降低耗能。現在要設計一項研究,比較兩種節能措施的效果:「Smart Thermostats」與「LED Lighting」。為了確保這項研究有足夠的檢定力,能偵測兩者在節能效果上的有意義差異,你將進行檢定力分析。

已載入 pandas as pdnumpy as np,以及 from statsmodels.stats.power import TTestIndPower

本練習屬於課程

Python 的實驗設計

檢視課程

練習說明

  • 建立一個 TTestIndPower 物件。
  • 進行檢定力分析,估計每一組(Smart Thermostats 與 LED Lighting)所需的樣本數,目標檢定力為 0.9,假設中等效果量(Cohen's d = 0.5),顯著水準 alpha 為 0.05,且兩組樣本數相同。

動手互動練習

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

# Instantiate a TTestIndPower object
power_analysis = ____

# Conduct a power analysis to determine the required sample size
required_n = power_analysis.solve_power(
    effect_size=____, 
    alpha=____, 
    power=____, 
    ratio=____)

print(required_n)
編輯並執行程式碼