Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
208 changes: 208 additions & 0 deletions .ipynb_checkpoints/Solutions-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Lab | Inferential statistics"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- It is assumed that the mean systolic blood pressure is `μ = 120 mm Hg`. In the Honolulu Heart Study, a sample of `n = 100` people had an average systolic blood pressure of 130.1 mm Hg with a standard deviation of 21.21 mm Hg. "
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"import datetime\n",
"import warnings\n",
"import matplotlib.pyplot as plt\n",
"import seaborn as sns\n",
"import math\n",
"from scipy.stats import ttest_ind\n",
"warnings.filterwarnings('ignore')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. Is the group significantly different (with respect to systolic blood pressure!) from the regular population?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.1 Set up the hypothesis test."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"see below"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.2 Write down all the steps followed for setting up the test."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"https://www.scribbr.com/statistics/hypothesis-testing/\n",
"<br>\n",
"Hypothesis testing is a formal procedure for investigating our ideas about the world using statistics. It is most often used by scientists to test specific predictions, called hypotheses, that arise from theories.\n",
"<br>\n",
"There are 5 main steps in hypothesis testing:<br>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### State your research hypothesis as null (H0) and alternate (Ha) hypothesis."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Ho: Systolic blood pressure, on average, not higher than regular population. <br>\n",
"Ha: Systolic blood pressure, on average, higher than regular population."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Collect data in a way designed to test the hypothesis."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"mean systolic blood pressure is μ = 120 mm Hg <br> \n",
"a sample of n = 100 people had an average systolic blood pressure of 130.1 mm Hg <br> \n",
"with a standard deviation of 21.21 mm Hg."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Perform an appropriate statistical test."
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"4.7619"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mean_population = 120\n",
"sample_mean = 130.1\n",
"stdev = 21.21\n",
"n = 100\n",
"\n",
"t = ((sample_mean - mean_population) / (stdev / math.sqrt(n)))\n",
"\n",
"round(t,5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Decide whether the null hypothesis is supported or refuted."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Present the findings in your results and discussion section."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1.3 Calculate the test statistic by hand and also code it in Python. It should be 4.76190. We will take a look at how to make decisions based on this calculated value."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"see 1.1.2.3"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2. If you finished the previous question, please go through the code for principal_component_analysis_example provided in the files_for_lab folder ."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading