def hypothesis_test(sample_a, sample_b):
"""Perform hypothesis test over two samples of measurements.
Uses Welch's t-test to check whether energy consumption
is different in the populations of samples a and b.
Args:
sample_a (list of Measurement): measurements of sample a
sample_b (list of Measurement): measurements of sample b
Returns:
t (float): The calculated t-statistic
prob (float): The two-tailed p-value
"""
return ttest_ind(
[measurement.energy_consumption for measurement in sample_a],
[measurement.energy_consumption for measurement in sample_b],
equal_var=False
)
评论列表
文章目录