<jupyter_start><jupyter_text>t-test<jupyter_code>import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import seaborn as sns # data visualization
import matplotlib.pyplot as plt #more data visualization
plt.style.use('fivethirtyeight')
import warnings
warnings.filterwarnings('ignore') # ignore warnings
from scipy.stats import ttest_ind # for the t-test we'll be doing
from subprocess import check_output 
#print(check_output(["ls", "../input"]).decode("utf8"))
#Are the amounts of sugar in cold cereal and hot cereal related?

cereal = pd.read_csv("/home/utkarsh/LearnBay/Statistics/cereal.csv")
cereal.head()
hot_cereal = cereal.loc[cereal['type'] == 'H', :] # define a hot_cereal df
cold_cereal = cereal.loc[cereal['type'] == 'C', :] # definte a cold_cereal df
ttest_ind(cold_cereal['sugars'], hot_cereal['sugars'], equal_var = False)
#Looks like our sugars are not the same! since the pvalue > .01, 
#we know that our null hypothesis (there is no correlation between the amount of sugars in hot cereal 
#and the amount of sugars in cold cereal)

#Check the Calories
ttest_ind(cold_cereal['calories'], hot_cereal['calories'], equal_var = False)
#Let's Visualize
ax = plt.subplots(figsize=(18,8)) # make our plot larger
# plot the cold cereal sugar distribution
sns.distplot(cold_cereal['sugars'], bins = 10, hist = True,  label = 'cold')
# plot the hot cereal sugar distribution
sns.distplot(hot_cereal['sugars'], bins = 10, hist = True, label = 'hot') 
plt.legend() #show legend<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1206896551724138, 'fraction_numerical': 0.006385696040868455, 'mean_word_length': 5.783549783549783, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '329549', 'license': 'Apache-2.0', 'n_tokens_mistral': 563, 'n_tokens_neox': 512, 'n_words': 167, 'path': 'Hypothesis Testing - 1.ipynb', 'repo_name': 'Abhishekjha111/statistics', 'size': '1566'}