diff --git a/your-code/main.ipynb b/your-code/main.ipynb index 332f496..6936159 100644 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -9,11 +9,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ - "# Libraries" + "import pandas as pd\n", + "import numpy as np\n", + "\n", + "import scipy.stats as st\n" ] }, { @@ -32,11 +35,50 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "left end: 169.66758574188816\n", + "right end: 177.26574759144518\n" + ] + } + ], "source": [ - "# your code here" + "heights = [167, 167, 168, 168, 168, 169, 171, 172, 173, 175, 175, 175, 177, 182, 195]\n", + "\n", + "s_mean = np.mean(heights)\n", + "s_std = np.std(heights, ddof=1)\n", + "n = len(heights)\n", + "confidence_level = 0.8\n", + "\n", + "Z_score = st.norm.ppf((1+confidence_level)/2)\n", + "\n", + "print(\"left end: \", s_mean-2*(s_std/np.sqrt(n)))\n", + "print(\"right end: \", s_mean+2*(s_std/np.sqrt(n)))" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(171.0323076132764, 175.90102572005694)" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "st.norm.interval(0.8, loc=s_mean, scale=s_std/np.sqrt(n))" ] }, { @@ -51,11 +93,50 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 13, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "left end: 0.178506830600482\n", + "right end: 0.3497950561919708\n" + ] + } + ], "source": [ - "# your code here" + "l_confidence_level = 0.8\n", + "n_confidence_level = 0.9\n", + "\n", + "x = list(np.arange(106))\n", + "x = [True if i <=27 else False for i in x]\n", + "mean = np.mean(x)\n", + "n = len(x)\n", + "std = np.std(x)\n", + "\n", + "print(\"left end: \", mean-2*(std/np.sqrt(n)))\n", + "print(\"right end: \", mean+2*(std/np.sqrt(n)))" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(0.20927226997969411, 0.3190296168127587)" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "st.norm.interval(0.8, loc=mean, scale=std/np.sqrt(n))" ] }, { @@ -131,7 +212,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -145,7 +226,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.11.3" } }, "nbformat": 4,