{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# GEOG 380L Lab 07: Inferential Statistics With Python -- Statistical Hypothesis Testing With Python\n",
"\n",
"Lecture Instructor: Dr. Liping Yang\n",
"\n",
"Lab instructor: Dr. Liping Yang "
]
},
{
"cell_type": "code",
"execution_count": 108,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"welcome to GEOG 380L Lab 07, the last Lab for GEOG380L!\n"
]
}
],
"source": [
"print (\"welcome to GEOG 380L Lab 07, the last Lab for GEOG380L!\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# In order to be able to learn statistics with Python, we need to learn the basic syntax and usages of python. No Python programming experience and Jupyter notebook usage expericen before? Do not worry. All the things will be covered through this course and we will learn as we build!\n",
"The goal of Lab 07\n",
"\n",
" Test how well you have mastered the theory and coding skills you have learned from both lecture along with demo using Python to do hypothesis testing tasks\n",
" Test how well you have mastered how to manipulate a given dataset using pandas and numpy libraries to solve hypothesis testing tasks.\n",
"\n",
"The total points of Lab 07, which contains four (4) tasks, are 30.\n",
"How to submit your lab assignments to UNM Learn.\n",
"\n",
"Important, read THIS before you work on your Lab 02 for how to submit your lab assignments to UNM Learn.\n",
"Task 00 -- importing required libraries and Loading the dataset (Dr. Yang has done this for you)\n",
"\n",
"We will use the same heart disease dataset we used in the lecture demo for this Lab. They are loaded below by Dr. Yang for you."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# Importing required libraries.\n",
"import pandas as pd\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
"\n",
"\n",
" | \n",
"age | \n",
"sex | \n",
"cp | \n",
"trestbps | \n",
"chol | \n",
"fbs | \n",
"restecg | \n",
"thalach | \n",
"exang | \n",
"oldpeak | \n",
"slope | \n",
"ca | \n",
"thal | \n",
"target | \n",
"
\n",
"\n",
"\n",
"\n",
"0 | \n",
"63 | \n",
"1 | \n",
"3 | \n",
"145 | \n",
"233 | \n",
"1 | \n",
"0 | \n",
"150 | \n",
"0 | \n",
"2.3 | \n",
"0 | \n",
"0 | \n",
"1 | \n",
"1 | \n",
"
\n",
"\n",
"1 | \n",
"37 | \n",
"1 | \n",
"2 | \n",
"130 | \n",
"250 | \n",
"0 | \n",
"1 | \n",
"187 | \n",
"0 | \n",
"3.5 | \n",
"0 | \n",
"0 | \n",
"2 | \n",
"1 | \n",
"
\n",
"\n",
"2 | \n",
"41 | \n",
"0 | \n",
"1 | \n",
"130 | \n",
"204 | \n",
"0 | \n",
"0 | \n",
"172 | \n",
"0 | \n",
"1.4 | \n",
"2 | \n",
"0 | \n",
"2 | \n",
"1 | \n",
"
\n",
"\n",
"3 | \n",
"56 | \n",
"1 | \n",
"1 | \n",
"120 | \n",
"236 | \n",
"0 | \n",
"1 | \n",
"178 | \n",
"0 | \n",
"0.8 | \n",
"2 | \n",
"0 | \n",
"2 | \n",
"1 | \n",
"
\n",
"\n",
"4 | \n",
"57 | \n",
"0 | \n",
"0 | \n",
"120 | \n",
"354 | \n",
"0 | \n",
"1 | \n",
"163 | \n",
"1 | \n",
"0.6 | \n",
"2 | \n",
"0 | \n",
"2 | \n",
"1 | \n",
"
\n",
"\n",
"
\n",
"
"
],
"text/plain": [
" age sex cp trestbps chol fbs restecg thalach exang oldpeak slope \\\n",
"0 63 1 3 145 233 1 0 150 0 2.3 0 \n",
"1 37 1 2 130 250 0 1 187 0 3.5 0 \n",
"2 41 0 1 130 204 0 0 172 0 1.4 2 \n",
"3 56 1 1 120 236 0 1 178 0 0.8 2 \n",
"4 57 0 0 120 354 0 1 163 1 ...