In this exercise, you will analyze a dataset of human body temperatures and employ the concepts of hypothesis testing, confidence intervals, and statistical significance.
Answer the following questions in this notebook below and submit to your Github account.
You can include written notes in notebook cells using Markdown:
In [1]:
import pandas as pd
df = pd.read_csv('data/human_body_temperature.csv')
In [2]:
# Your work here.
In [3]:
# Load Matplotlib + Seaborn and SciPy libraries
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from scipy import stats
%matplotlib inline
In [4]:
df.head(5)
Out[4]:
Yes. Based on the shape of the curve plotted with sample data, we have a normal distribution of body temperature.
In [5]:
ax = sns.distplot(df[['temperature']], rug=True, axlabel='Temperature (o F)')
Yes. We have 390 records in the sample data file (df.size).
There is no connection or dependence between the measured temperature values, in other words, the observations are independent.
In [6]:
# Sample (dataset) size
df['temperature'].describe()
Out[6]:
In [7]:
# Population mean temperature
POP_MEAN = 98.6
# Sample size, mean and standard deviation
sample_size = df['temperature'].count()
sample_mean = df['temperature'].mean()
sample_std = df['temperature'].std(axis=0)
In [8]:
print("Population mean temperature (given): POP_MEAN = " + str(POP_MEAN))
print("Sample size: sample_size = " + str(sample_size))
print("Sample mean: sample_mean = "+ str(sample_mean))
print("Sample standard deviation: sample_std = "+ str(sample_std))
In [9]:
# t distribuition
# t = ((sample_mean - reference_value)/ std_deviation ) * sqrt(sample_size)
# ...
In [10]:
# degrees of freedom
degree = 130 - 1
In [12]:
# p-value
# p = stats.t.cdf(t,df=degree)
In [13]:
# t-stats and p-value
# print("t = " + str(t))
# print("p = " + str(2*p))
a) Would you use a one-sample or two-sample test? Why?
b) In this situation, is it appropriate to use the t or z statistic?
c) Now try using the other test. How is the result be different? Why?
In [54]:
# A sample with randomly 10 records from original dataset
df_sample10 = df.sample(n=10)
The histogram:
In [47]:
ax = sns.distplot(df_sample10[['temperature']], rug=True, axlabel='Temperature (o F)')
What test did you use and why?
Write a story with your conclusion in the context of the original problem.
[1] "What Statistical Analysis Should I Use? Statistical Analyses Using STATA". Last access: 12/25/2017 - Link: https://stats.idre.ucla.edu/stata/whatstat/what-statistical-analysis-should-i-usestatistical-analyses-using-stata/
[2] "T-Score vs. Z-Score: What’s the Difference?". Last access: 12/26/2017 - Link: http://www.statisticshowto.com/when-to-use-a-t-score-vs-z-score/
[x] "Central limit theorem", Khan Acadeny. Last access: 12/26/2017. Link: https://www.khanacademy.org/math/ap-statistics/sampling-distribution-ap/sampling-distribution-mean/v/sampling-distribution-of-the-sample-mean
In [ ]: