Created
January 14, 2020 07:45
-
-
Save Suchana34/606db74dec3d22567ebdd4512a54029a to your computer and use it in GitHub Desktop.
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": 7, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
" Name Score\n", | |
"0 Tom 66\n", | |
"1 nick 71\n", | |
"2 krish 49\n", | |
"3 jack 58\n", | |
"4 sam 61\n" | |
] | |
} | |
], | |
"source": [ | |
"#creating a dataset from scratch into pandas\n", | |
"data = {'Name':['Tom', 'nick', 'krish', 'jack', 'sam'],\n", | |
" 'Score':[66, 71, 49, 58, 61]}\n", | |
"# Creating DataFrame\n", | |
"grade_df = pd.DataFrame(data)\n", | |
" \n", | |
"print(grade_df)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 54, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"(-1.4907119849998598, 0.06801856405707181)" | |
] | |
}, | |
"execution_count": 54, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"#lets define a method for z-test which takes population mean, variance and the sample to calculate and return z-score and p-value\n", | |
"import math\n", | |
"def z_test(pop_mean, pop_std, sample):\n", | |
" z_score = (sample.mean() - pop_mean)/(pop_std/math.sqrt(len(sample)))\n", | |
" return z_score, stats.norm.cdf(z_score)\n", | |
"\n", | |
"z_test(67, 9.0, grade_df.Score)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"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.7.1" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment