Get startedGet started for free

Estimating required sample size for energy study

In the energy sector, researchers are often tasked with evaluating the effectiveness of new technologies or initiatives to enhance energy efficiency or reduce consumption. A study is being designed to compare the impact of two energy-saving measures: "Smart Thermostats" and "LED Lighting". To ensure the study has sufficient power to detect a meaningful difference in energy savings between these two measures, you'll conduct a power analysis.

pandas as pd, numpy as np, and from statsmodels.stats.power import TTestIndPower are loaded.

This exercise is part of the course

Experimental Design in Python

View Course

Exercise instructions

  • Instantiate a TTestIndPower object.
  • Conduct the power analysis to estimate the required sample size for each group (Smart Thermostats and LED Lighting) to achieve a power of 0.9, assuming a moderate effect size (Cohen's d = 0.5) and an alpha of 0.05 with an equal sized groups.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# 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)
Edit and Run Code