diff --git a/your-code/main.ipynb b/your-code/main.ipynb index 332f496..b86e3e0 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" + "# Libraries\n", + "import pandas as pd\n", + "import numpy as np\n", + "import scipy.stats as st" ] }, { @@ -32,11 +35,28 @@ }, { "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" + "# your code here\n", + "heights = [167, 167, 168, 168, 168, 169, 171, 172, 173, 175, 175, 175, 177, 182, 195]\n", + "std = 4 # of the population\n", + "mean = sum(heights)/len(heights)\n", + "mean\n", + "n = len(heights)\n", + "st.norm.interval(0.80,loc=mean,scale=std/np.sqrt(n))" ] }, { @@ -51,11 +71,60 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "import scipy.stats as stats\n", + "import numpy as np" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "# CONFIDENCE INTERVALS WITH PROPORTION" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(0.20248138545542083, 0.3118043288302934)\n", + "(0.18698561776452813, 0.3273000965211861)\n" + ] + } + ], + "source": [ + "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)" ] }, { @@ -76,7 +145,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ @@ -94,7 +163,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ @@ -121,17 +190,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "# your code here" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -145,7 +221,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.11.5" } }, "nbformat": 4,