<jupyter_start><jupyter_text>What if the variances are different? ![image.png](attachment:image.png)<jupyter_code>sample_a = [6625,6000,5450,5200,5175,4900,4750,4500,3985,900,450,2800]
sample_b = [3900,3500,3450,3200,2980,2800,2500,2400,2200,1200,1150,1130]
n = len(sample_a)
mean_a = np.mean(sample_a)
var_a = np.var(sample_a, ddof=1)
sd_a = var_a**(1/2)

mean_b = np.mean(sample_b)
var_b = np.var(sample_b, ddof=1)
sd_b = var_b**(1/2)
t0 = (mean_a-mean_b)/(np.sqrt(var_a/n+var_b/n))
t0
v = (var_a/n+var_b/n)**2 / ((var_a/n)**2/(n-1) + (var_b/n)**2/(n-1))
v
t_dist = stats.t(v)
1 - t_dist.cdf(t0)
from scipy.stats import ttest_ind
ttest_ind(sample_a, sample_b, axis=0, equal_var=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19692737430167598, 'fraction_numerical': 0.15363128491620112, 'mean_word_length': 7.1477272727272725, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '198623', 'license': 'Apache-2.0', 'n_tokens_mistral': 427, 'n_tokens_neox': 364, 'n_words': 46, 'path': 'Applied Analytics/Design of Experiments/Experimental Design Basics/Week 2/Hypothesis Testing on Variances.ipynb', 'repo_name': 'weynars/master-of-data-science-strategy-and-leadership', 'size': '716'}