From 6dbdc086c85b2d99b0cd5539dabc3e58d356ff3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20S=C3=A1nchez?= Date: Mon, 5 Jun 2023 06:32:34 +0100 Subject: [PATCH] [lab-confidence-intervals] Javier Sanchez Camacho --- your-code/main.ipynb | 47 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/your-code/main.ipynb b/your-code/main.ipynb index 332f496..99c211f 100644 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -9,11 +9,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ - "# Libraries" + "# Libraries\n", + "from scipy import stats\n", + "import numpy as np" ] }, { @@ -32,11 +34,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(172.14308590115726, 174.79024743217607)" + ] + }, + "execution_count": 2, + "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", + "ci = stats.norm.interval(0.8, loc=np.mean(heights), scale=4/np.sqrt(len(heights)))\n", + "ci" ] }, { @@ -51,11 +66,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(0.20248138545542083, 0.3118043288302934)\n", + "(0.1869856177645281, 0.3273000965211861)\n" + ] + } + ], "source": [ - "# your code here" + "s = 27\n", + "n = 105\n", + "p = 27/105\n", + "stdev = np.sqrt((p*(1-p))/n)\n", + "print(stats.norm.interval(0.8, loc=p, scale=stdev))\n", + "print(stats.norm.interval(0.9, loc=p, scale=stdev))" ] }, { @@ -145,7 +174,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.10.9" } }, "nbformat": 4,