From 5c9822acba8835412e7d7a4d1b09460706483a9d Mon Sep 17 00:00:00 2001 From: YaraLis Date: Thu, 14 Dec 2023 19:06:25 +0000 Subject: [PATCH] lab done --- your-code/main.ipynb | 68 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 9 deletions(-) diff --git a/your-code/main.ipynb b/your-code/main.ipynb index 332f496..5d9d389 100644 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -9,11 +9,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ - "# Libraries" + "# Libraries\n", + "import scipy.stats as st\n", + "import numpy as np" ] }, { @@ -32,11 +34,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(172.14308590115726, 174.79024743217607)" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# your code here" + "heights = [167, 167, 168, 168, 168, 169, 171, 172, 173, 175, 175, 175, 177, 182, 195]\n", + "std = 4 \n", + "mean = sum(heights)/len(heights)\n", + "x = len(heights)\n", + "st.norm.interval(0.80,loc=mean,scale=std/np.sqrt(x))" ] }, { @@ -51,11 +68,44 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(0.20248138545542083, 0.3118043288302934)\n", + "(0.18698561776452813, 0.3273000965211861)\n" + ] + } + ], "source": [ - "# your code here" + "import numpy as np\n", + "from scipy import stats\n", + "\n", + "total = 105\n", + "losses = 27\n", + "\n", + "sample_proportion = losses / total\n", + "\n", + "confidence_80 = 0.80\n", + "confidence_90 = 0.90\n", + "\n", + "standard_error = np.sqrt((sample_proportion * (1 - sample_proportion)) / total)\n", + "\n", + "z_score_80 = stats.norm.ppf((1 + confidence_80) / 2)\n", + "z_score_90 = stats.norm.ppf((1 + confidence_90) / 2)\n", + "\n", + "margin_of_error_80 = z_score_80 * standard_error\n", + "margin_of_error_90 = z_score_90 * standard_error\n", + "\n", + "confidence_interval_80 = (sample_proportion - margin_of_error_80, sample_proportion + margin_of_error_80)\n", + "confidence_interval_90 = (sample_proportion - margin_of_error_90, sample_proportion + margin_of_error_90)\n", + "\n", + "\n", + "print(confidence_interval_80)\n", + "print(confidence_interval_90)" ] }, { @@ -145,7 +195,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.11.5" } }, "nbformat": 4,