Experimental Design in Python
James Chapman
Curriculum Manager, DataCamp
P-values: probability of observing our data if the null hypothesis was true
$\alpha$: threshold at which we consider our results statistically significant
P-value $\le \alpha$: Reject null in favor of alternative hypothesis
crop_yields.head()
Fertilizer_Type Crop_Yield
0 Organic 26.225
1 Synthetic 17.452
2 Organic 22.283
3 Synthetic 23.548
4 Synthetic 24.138
import seaborn as sns
sns.displot(data=crop_data, x="Crop_Yield", hue="Fertilizer_Type", kind="kde")
$\alpha = 0.05$
from scipy.stats import ttest_ind
organic_yield = crop_yields[crop_yields['Fertilizer_Type'] == 'Organic']
['Crop_Yield']
synthetic_yield = crop_yields[crop_yields['Fertilizer_Type'] == 'Synthetic']
['Crop_Yield']
t_stat, p_val = ttest_ind(organic_yield, synthetic_yield)
print(p_val)
1.8496748715743899e-209
Experimental Design in Python