Created
January 21, 2019 10:41
-
-
Save onpillow/ca226c9b0f67ecf6f8177d123e38680d to your computer and use it in GitHub Desktop.
Medium_06_1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"import matplotlib.pyplot as plt" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array([102, 435, 348, 270, 106, 71, 188, 20, 102, 121, 466, 214, 330,\n", | |
" 458, 87, 372, 99, 359, 151, 130, 149, 308, 257, 343, 491, 413,\n", | |
" 293, 385, 191, 443, 276, 160, 459, 313, 21, 252, 235, 344, 48,\n", | |
" 474, 58, 169, 475, 187, 463, 270, 189, 445, 174, 445, 50, 363,\n", | |
" 54, 243, 319, 130, 484, 306, 134, 20, 328, 166, 273, 387, 88,\n", | |
" 315, 13, 241, 264, 345, 52, 385, 339, 91, 366, 443, 454, 427,\n", | |
" 263, 430, 34, 205, 80, 419, 49, 359, 387, 1, 389, 53, 105,\n", | |
" 259, 309, 476, 190, 401, 217, 43, 161, 201])" | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# construct a population pickups for our lab\n", | |
"np.random.seed(42)\n", | |
"pickups = np.random.randint(0,500 , size=100)\n", | |
"pickups" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"252.7" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# population mean\n", | |
"pickups.mean()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"144.25342283634035" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# population standard deviation\n", | |
"pickups.std()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": { | |
"scrolled": true | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"array([166, 201, 458, 190, 445, 87, 385, 427, 387, 166, 474, 49, 430,\n", | |
" 205, 54, 343, 413, 389, 20, 58, 191, 87, 463, 88, 389, 52,\n", | |
" 102, 1, 102, 20])" | |
] | |
}, | |
"execution_count": 5, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# draw a sample from population\n", | |
"sample = np.random.choice(pickups, size=30)\n", | |
"sample" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"228.06666666666666" | |
] | |
}, | |
"execution_count": 6, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# our first sample mean\n", | |
"sample_mean = sample.mean()\n", | |
"sample_mean" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"166.96890756052164" | |
] | |
}, | |
"execution_count": 7, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# standard deiveation for this sample\n", | |
"sample_std = np.std(sample, ddof=1)\n", | |
"sample_std" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"30.48421235763086" | |
] | |
}, | |
"execution_count": 8, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# estimated standard error for the sapmle mann\n", | |
"sample_std/(30 ** 0.5)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python [conda env:Anaconda3]", | |
"language": "python", | |
"name": "conda-env-Anaconda3-py" | |
}, | |
"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.6.4" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment